From 848fd484d59a91fc88e142d0047f571840087283 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 7 Sep 2023 11:38:34 +0100 Subject: [PATCH] MDL-79279 qformat_xml: multianswer import should support idnumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix suggested by Georg Maißer. --- question/format/xml/format.php | 2 ++ question/format/xml/tests/xmlformat_test.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index b50dae39b1a..09d5802217d 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -535,6 +535,8 @@ class qformat_xml extends qformat_default { $qo->questiontext .= ' '; } + $qo->idnumber = $this->getpath($question, ['#', 'idnumber', 0, '#'], null); + // Restore files in generalfeedback. $generalfeedback = $this->import_text_with_files($question, array('#', 'generalfeedback', 0), '', $this->get_format($qo->questiontextformat)); diff --git a/question/format/xml/tests/xmlformat_test.php b/question/format/xml/tests/xmlformat_test.php index 0101066a3e1..fd8138819c7 100644 --- a/question/format/xml/tests/xmlformat_test.php +++ b/question/format/xml/tests/xmlformat_test.php @@ -1588,6 +1588,7 @@ END; 0.5 0 + id-101 Hint 1 @@ -1612,6 +1613,7 @@ END; $expectedqa->name = 'Simple multianswer'; $expectedqa->qtype = 'multianswer'; $expectedqa->questiontext = 'Complete this opening line of verse: "The {#1} and the {#2} went to sea".'; + $expectedqa->idnumber = 'id-101'; $expectedqa->generalfeedback = 'General feedback: It\'s from "The Owl and the Pussy-cat" by Lear: "The owl and the pussycat went to sea".'; $expectedqa->defaultmark = 2;