CVE-2018-14630
Description
Moodle XML import of legacy drag-and-drop quiz questions allows PHP code injection and remote code execution before versions 3.5.2, 3.4.5, 3.3.8, and 3.1.14.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Moodle XML import of legacy drag-and-drop quiz questions allows PHP code injection and remote code execution before versions 3.5.2, 3.4.5, 3.3.8, and 3.1.14.
Vulnerability
A PHP code injection vulnerability exists in the legacy import format for "drag and drop into text" (ddwtos) quiz questions in Moodle [1]. Affected versions are those before 3.5.2, 3.4.5, 3.3.8, and 3.1.14 [1]. The import parser did not properly sanitize data from the XML structure, allowing arbitrary PHP code to be embedded within question definitions [1].
Exploitation
An attacker must have the ability to import quiz questions (either as a teacher or by supplying a crafted XML file to an administrator) [1]. By embedding PHP code within the `` or other elements of the legacy ddwtos XML format, the attacker can cause the server to execute that code when the question is imported or used [1]. The legacy import code path was removed in the security fix, as shown in the commit diffs [2][3][4].
Impact
Successful exploitation leads to arbitrary remote code execution on the Moodle server with the privileges of the web server process [1]. This could result in full compromise of the Moodle installation, including access to user data, course content, and the ability to further attack the server.
Mitigation
Moodle released fixed versions on 2018-09-17: 3.5.2, 3.4.5, 3.3.8, and 3.1.14 [1]. Administrators should upgrade to these or later versions immediately. The fix removes support for the legacy ddwtos import format, which was the vulnerable code path [2][3][4]. No workaround is available if the upgrade cannot be performed; administrators should disable the ability for untrusted users to import questions.
AI Insight generated on May 22, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
moodle/moodlePackagist | >= 3.5.0, < 3.5.2 | 3.5.2 |
moodle/moodlePackagist | >= 3.4.0, < 3.4.5 | 3.4.5 |
moodle/moodlePackagist | >= 3.2.0, < 3.3.8 | 3.3.8 |
moodle/moodlePackagist | < 3.1.14 | 3.1.14 |
Affected products
1Patches
9bd27666c42beMoodle release 3.5.2
1 file changed · +2 −2
version.php+2 −2 modified@@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2018051701.11; // 20180517 = branching date YYYYMMDD - do not modify! +$version = 2018051702.00; // 20180517 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -$release = '3.5.1+ (Build: 20180907)'; // Human-friendly version name +$release = '3.5.2 (Build: 20180910)'; // Human-friendly version name $branch = '35'; // This version's branch. $maturity = MATURITY_STABLE; // This version's maturity level.
28f6460de388Moodle release 3.4.5
1 file changed · +2 −2
version.php+2 −2 modified@@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017111304.11; // 20171113 = branching date YYYYMMDD - do not modify! +$version = 2017111305.00; // 20171113 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -$release = '3.4.4+ (Build: 20180907)'; // Human-friendly version name +$release = '3.4.5 (Build: 20180910)'; // Human-friendly version name $branch = '34'; // This version's branch. $maturity = MATURITY_STABLE; // This version's maturity level.
c37329dc1063Moodle release 3.3.8
1 file changed · +2 −2
version.php+2 −2 modified@@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017051507.07; // 20170515 = branching date YYYYMMDD - do not modify! +$version = 2017051508.00; // 20170515 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -$release = '3.3.7+ (Build: 20180907)'; // Human-friendly version name +$release = '3.3.8 (Build: 20180910)'; // Human-friendly version name $branch = '33'; // This version's branch. $maturity = MATURITY_STABLE; // This version's maturity level.
b45c238223beMoodle release 3.1.14
1 file changed · +2 −2
version.php+2 −2 modified@@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2016052313.03; // 20160523 = branching date YYYYMMDD - do not modify! +$version = 2016052314.00; // 20160523 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -$release = '3.1.13+ (Build: 20180907)'; // Human-friendly version name +$release = '3.1.14 (Build: 20180910)'; // Human-friendly version name $branch = '31'; // This version's branch. $maturity = MATURITY_STABLE; // This version's maturity level.
be092b730910MDL-62880 qtype_ddwtos: drop support for legacy import format
2 files changed · +11 −219
question/type/ddwtos/questiontype.php+11 −26 modified@@ -71,32 +71,17 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu $question->shuffleanswers = $format->trans_single( $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1)); - if (!empty($data['#']['dragbox'])) { - // Modern XML format. - $dragboxes = $data['#']['dragbox']; - $question->answer = array(); - $question->draggroup = array(); - $question->infinite = array(); - - foreach ($data['#']['dragbox'] as $dragboxxml) { - $question->choices[] = array( - 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), - 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), - 'infinite' => array_key_exists('infinite', $dragboxxml['#']), - ); - } - - } else { - // Legacy format containing PHP serialisation. - foreach ($data['#']['answer'] as $answerxml) { - $ans = $format->import_answer($answerxml); - $options = unserialize(stripslashes($ans->feedback['text'])); - $question->choices[] = array( - 'answer' => $ans->answer, - 'choicegroup' => $options->draggroup, - 'infinite' => $options->infinite, - ); - } + // Import the choices. + $question->answer = array(); + $question->draggroup = array(); + $question->infinite = array(); + + foreach ($data['#']['dragbox'] as $dragboxxml) { + $question->choices[] = array( + 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), + 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), + 'infinite' => array_key_exists('infinite', $dragboxxml['#']), + ); } $format->import_combined_feedback($question, $data, true);
question/type/ddwtos/tests/questiontype_test.php+0 −193 modified@@ -243,199 +243,6 @@ public function test_xml_import() { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_import_legacy() { - $xml = ' <question type="ddwtos"> - <name> - <text>QDandD1 Base definition</text> - </name> - <questiontext format="html"> - <text><p>Drag and drop the words from the list below to fill the blank spaces ' . - 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . - 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . - 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . - '<!--DONOTCLEAN--></text> - </questiontext> - <image></image> - <generalfeedback> - <text><p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . - 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . - 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . - '<p>See Section 9 of S103 <em class="italic">Discovering ' . - 'Science</em> Block 8.</p></text> - </generalfeedback> - <defaultgrade>1</defaultgrade> - <penalty>0.33</penalty> - <hidden>0</hidden> - <shuffleanswers>0</shuffleanswers> - <shuffleanswers>false</shuffleanswers> - <answer> - <correctanswer>1</correctanswer> - <text>hydrogen</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>positive</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>hydroxide</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>negative</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>10<sup>7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>7</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>1</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>10<sup>-7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>greater</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>less</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <correctfeedback> - <text>Your answer is correct.</text> - </correctfeedback> - <correctresponsesfeedback>1</correctresponsesfeedback> - <partiallycorrectfeedback> - <text>Your answer is partially correct.</text> - </partiallycorrectfeedback> - <incorrectfeedback> - <text>Your answer is incorrect.</text> - </incorrectfeedback> - <unlimited>0</unlimited> - <penalty>0.33</penalty> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>0</clearincorrectresponses> - <hintcontent> - <text>You may wish to read Section 9 of <em ' . - 'class="italic">Discovering Science</em> Block 8.</text> - </hintcontent> - </hint> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>1</clearincorrectresponses> - <hintcontent> - <text>Any incorrect choices will be removed before your final try.</text> - </hintcontent> - </hint> - </question>'; - $xmldata = xmlize($xml); - - $importer = new qformat_xml(); - $q = $importer->try_importing_using_qtypes( - $xmldata['question'], null, null, 'ddwtos'); - - $expectedq = new stdClass(); - $expectedq->qtype = 'ddwtos'; - $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '<p>Drag and drop the words from the list below ' . - 'to fill the blank spaces and correctly complete the sentence.</p>' . - '<p>At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . - 'less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p>' . - '<!--DONOTCLEAN-->'; - $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '<p>At 25 °C all aqueous basic solutions ' . - 'have hydrogen ion concentrations less than 10<sup>−7</sup> ' . - 'mol litre<sup>−1</sup> and pH values greater than 7.</p><p>See ' . - 'Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>'; - $expectedq->defaultmark = 1; - $expectedq->length = 1; - $expectedq->penalty = 0.3333333; - - $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', - 'format' => FORMAT_HTML); - $expectedq->partiallycorrectfeedback = array( - 'text' => 'Your answer is partially correct.', - 'format' => FORMAT_HTML); - $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', - 'format' => FORMAT_HTML); - - $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - ); - - $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . - '<em class="italic">Discovering Science</em> Block 8.', - 'format' => FORMAT_HTML), - array('text' => 'Any incorrect choices will be removed before your final try.', - 'format' => FORMAT_HTML), - ); - $expectedq->hintshownumcorrect = array(true, true); - $expectedq->hintclearwrong = array(false, true); - - $this->assert(new question_check_specified_fields_expectation($expectedq), $q); - $this->assertEquals($expectedq->choices, $q->choices); - $this->assertEquals($expectedq->hint, $q->hint); - } - public function test_xml_export() { $qdata = new stdClass(); $qdata->id = 123;
cfc4393aa689MDL-62880 qtype_ddwtos: drop support for legacy import format
2 files changed · +11 −219
question/type/ddwtos/questiontype.php+11 −26 modified@@ -71,32 +71,17 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu $question->shuffleanswers = $format->trans_single( $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1)); - if (!empty($data['#']['dragbox'])) { - // Modern XML format. - $dragboxes = $data['#']['dragbox']; - $question->answer = array(); - $question->draggroup = array(); - $question->infinite = array(); - - foreach ($data['#']['dragbox'] as $dragboxxml) { - $question->choices[] = array( - 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), - 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), - 'infinite' => array_key_exists('infinite', $dragboxxml['#']), - ); - } - - } else { - // Legacy format containing PHP serialisation. - foreach ($data['#']['answer'] as $answerxml) { - $ans = $format->import_answer($answerxml); - $options = unserialize(stripslashes($ans->feedback['text'])); - $question->choices[] = array( - 'answer' => $ans->answer, - 'choicegroup' => $options->draggroup, - 'infinite' => $options->infinite, - ); - } + // Import the choices. + $question->answer = array(); + $question->draggroup = array(); + $question->infinite = array(); + + foreach ($data['#']['dragbox'] as $dragboxxml) { + $question->choices[] = array( + 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), + 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), + 'infinite' => array_key_exists('infinite', $dragboxxml['#']), + ); } $format->import_combined_feedback($question, $data, true);
question/type/ddwtos/tests/questiontype_test.php+0 −193 modified@@ -243,199 +243,6 @@ public function test_xml_import() { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_import_legacy() { - $xml = ' <question type="ddwtos"> - <name> - <text>QDandD1 Base definition</text> - </name> - <questiontext format="html"> - <text><p>Drag and drop the words from the list below to fill the blank spaces ' . - 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . - 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . - 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . - '<!--DONOTCLEAN--></text> - </questiontext> - <image></image> - <generalfeedback> - <text><p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . - 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . - 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . - '<p>See Section 9 of S103 <em class="italic">Discovering ' . - 'Science</em> Block 8.</p></text> - </generalfeedback> - <defaultgrade>1</defaultgrade> - <penalty>0.33</penalty> - <hidden>0</hidden> - <shuffleanswers>0</shuffleanswers> - <shuffleanswers>false</shuffleanswers> - <answer> - <correctanswer>1</correctanswer> - <text>hydrogen</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>positive</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>hydroxide</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>negative</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>10<sup>7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>7</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>1</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>10<sup>-7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>greater</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>less</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <correctfeedback> - <text>Your answer is correct.</text> - </correctfeedback> - <correctresponsesfeedback>1</correctresponsesfeedback> - <partiallycorrectfeedback> - <text>Your answer is partially correct.</text> - </partiallycorrectfeedback> - <incorrectfeedback> - <text>Your answer is incorrect.</text> - </incorrectfeedback> - <unlimited>0</unlimited> - <penalty>0.33</penalty> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>0</clearincorrectresponses> - <hintcontent> - <text>You may wish to read Section 9 of <em ' . - 'class="italic">Discovering Science</em> Block 8.</text> - </hintcontent> - </hint> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>1</clearincorrectresponses> - <hintcontent> - <text>Any incorrect choices will be removed before your final try.</text> - </hintcontent> - </hint> - </question>'; - $xmldata = xmlize($xml); - - $importer = new qformat_xml(); - $q = $importer->try_importing_using_qtypes( - $xmldata['question'], null, null, 'ddwtos'); - - $expectedq = new stdClass(); - $expectedq->qtype = 'ddwtos'; - $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '<p>Drag and drop the words from the list below ' . - 'to fill the blank spaces and correctly complete the sentence.</p>' . - '<p>At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . - 'less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p>' . - '<!--DONOTCLEAN-->'; - $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '<p>At 25 °C all aqueous basic solutions ' . - 'have hydrogen ion concentrations less than 10<sup>−7</sup> ' . - 'mol litre<sup>−1</sup> and pH values greater than 7.</p><p>See ' . - 'Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>'; - $expectedq->defaultmark = 1; - $expectedq->length = 1; - $expectedq->penalty = 0.3333333; - - $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', - 'format' => FORMAT_HTML); - $expectedq->partiallycorrectfeedback = array( - 'text' => 'Your answer is partially correct.', - 'format' => FORMAT_HTML); - $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', - 'format' => FORMAT_HTML); - - $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - ); - - $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . - '<em class="italic">Discovering Science</em> Block 8.', - 'format' => FORMAT_HTML), - array('text' => 'Any incorrect choices will be removed before your final try.', - 'format' => FORMAT_HTML), - ); - $expectedq->hintshownumcorrect = array(true, true); - $expectedq->hintclearwrong = array(false, true); - - $this->assert(new question_check_specified_fields_expectation($expectedq), $q); - $this->assertEquals($expectedq->choices, $q->choices); - $this->assertEquals($expectedq->hint, $q->hint); - } - public function test_xml_export() { $qdata = new stdClass(); $qdata->id = 123;
09cbca8566a3MDL-62880 qtype_ddwtos: drop support for legacy import format
2 files changed · +11 −219
question/type/ddwtos/questiontype.php+11 −26 modified@@ -71,32 +71,17 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu $question->shuffleanswers = $format->trans_single( $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1)); - if (!empty($data['#']['dragbox'])) { - // Modern XML format. - $dragboxes = $data['#']['dragbox']; - $question->answer = array(); - $question->draggroup = array(); - $question->infinite = array(); - - foreach ($data['#']['dragbox'] as $dragboxxml) { - $question->choices[] = array( - 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), - 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), - 'infinite' => array_key_exists('infinite', $dragboxxml['#']), - ); - } - - } else { - // Legacy format containing PHP serialisation. - foreach ($data['#']['answer'] as $answerxml) { - $ans = $format->import_answer($answerxml); - $options = unserialize(stripslashes($ans->feedback['text'])); - $question->choices[] = array( - 'answer' => $ans->answer, - 'choicegroup' => $options->draggroup, - 'infinite' => $options->infinite, - ); - } + // Import the choices. + $question->answer = array(); + $question->draggroup = array(); + $question->infinite = array(); + + foreach ($data['#']['dragbox'] as $dragboxxml) { + $question->choices[] = array( + 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), + 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), + 'infinite' => array_key_exists('infinite', $dragboxxml['#']), + ); } $format->import_combined_feedback($question, $data, true);
question/type/ddwtos/tests/questiontype_test.php+0 −193 modified@@ -243,199 +243,6 @@ public function test_xml_import() { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_import_legacy() { - $xml = ' <question type="ddwtos"> - <name> - <text>QDandD1 Base definition</text> - </name> - <questiontext format="html"> - <text><p>Drag and drop the words from the list below to fill the blank spaces ' . - 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . - 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . - 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . - '<!--DONOTCLEAN--></text> - </questiontext> - <image></image> - <generalfeedback> - <text><p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . - 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . - 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . - '<p>See Section 9 of S103 <em class="italic">Discovering ' . - 'Science</em> Block 8.</p></text> - </generalfeedback> - <defaultgrade>1</defaultgrade> - <penalty>0.33</penalty> - <hidden>0</hidden> - <shuffleanswers>0</shuffleanswers> - <shuffleanswers>false</shuffleanswers> - <answer> - <correctanswer>1</correctanswer> - <text>hydrogen</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>positive</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>hydroxide</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>negative</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>10<sup>7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>7</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>1</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>10<sup>-7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>greater</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>less</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <correctfeedback> - <text>Your answer is correct.</text> - </correctfeedback> - <correctresponsesfeedback>1</correctresponsesfeedback> - <partiallycorrectfeedback> - <text>Your answer is partially correct.</text> - </partiallycorrectfeedback> - <incorrectfeedback> - <text>Your answer is incorrect.</text> - </incorrectfeedback> - <unlimited>0</unlimited> - <penalty>0.33</penalty> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>0</clearincorrectresponses> - <hintcontent> - <text>You may wish to read Section 9 of <em ' . - 'class="italic">Discovering Science</em> Block 8.</text> - </hintcontent> - </hint> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>1</clearincorrectresponses> - <hintcontent> - <text>Any incorrect choices will be removed before your final try.</text> - </hintcontent> - </hint> - </question>'; - $xmldata = xmlize($xml); - - $importer = new qformat_xml(); - $q = $importer->try_importing_using_qtypes( - $xmldata['question'], null, null, 'ddwtos'); - - $expectedq = new stdClass(); - $expectedq->qtype = 'ddwtos'; - $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '<p>Drag and drop the words from the list below ' . - 'to fill the blank spaces and correctly complete the sentence.</p>' . - '<p>At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . - 'less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p>' . - '<!--DONOTCLEAN-->'; - $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '<p>At 25 °C all aqueous basic solutions ' . - 'have hydrogen ion concentrations less than 10<sup>−7</sup> ' . - 'mol litre<sup>−1</sup> and pH values greater than 7.</p><p>See ' . - 'Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>'; - $expectedq->defaultmark = 1; - $expectedq->length = 1; - $expectedq->penalty = 0.3333333; - - $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', - 'format' => FORMAT_HTML); - $expectedq->partiallycorrectfeedback = array( - 'text' => 'Your answer is partially correct.', - 'format' => FORMAT_HTML); - $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', - 'format' => FORMAT_HTML); - - $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - ); - - $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . - '<em class="italic">Discovering Science</em> Block 8.', - 'format' => FORMAT_HTML), - array('text' => 'Any incorrect choices will be removed before your final try.', - 'format' => FORMAT_HTML), - ); - $expectedq->hintshownumcorrect = array(true, true); - $expectedq->hintclearwrong = array(false, true); - - $this->assert(new question_check_specified_fields_expectation($expectedq), $q); - $this->assertEquals($expectedq->choices, $q->choices); - $this->assertEquals($expectedq->hint, $q->hint); - } - public function test_xml_export() { $qdata = new stdClass(); $qdata->id = 123;
da1eeea0ff3dMDL-62880 qtype_ddwtos: drop support for legacy import format
2 files changed · +11 −219
question/type/ddwtos/questiontype.php+11 −26 modified@@ -71,32 +71,17 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu $question->shuffleanswers = $format->trans_single( $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1)); - if (!empty($data['#']['dragbox'])) { - // Modern XML format. - $dragboxes = $data['#']['dragbox']; - $question->answer = array(); - $question->draggroup = array(); - $question->infinite = array(); - - foreach ($data['#']['dragbox'] as $dragboxxml) { - $question->choices[] = array( - 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), - 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), - 'infinite' => array_key_exists('infinite', $dragboxxml['#']), - ); - } - - } else { - // Legacy format containing PHP serialisation. - foreach ($data['#']['answer'] as $answerxml) { - $ans = $format->import_answer($answerxml); - $options = unserialize(stripslashes($ans->feedback['text'])); - $question->choices[] = array( - 'answer' => $ans->answer, - 'choicegroup' => $options->draggroup, - 'infinite' => $options->infinite, - ); - } + // Import the choices. + $question->answer = array(); + $question->draggroup = array(); + $question->infinite = array(); + + foreach ($data['#']['dragbox'] as $dragboxxml) { + $question->choices[] = array( + 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), + 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), + 'infinite' => array_key_exists('infinite', $dragboxxml['#']), + ); } $format->import_combined_feedback($question, $data, true);
question/type/ddwtos/tests/questiontype_test.php+0 −193 modified@@ -243,199 +243,6 @@ public function test_xml_import() { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_import_legacy() { - $xml = ' <question type="ddwtos"> - <name> - <text>QDandD1 Base definition</text> - </name> - <questiontext format="html"> - <text><p>Drag and drop the words from the list below to fill the blank spaces ' . - 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . - 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . - 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . - '<!--DONOTCLEAN--></text> - </questiontext> - <image></image> - <generalfeedback> - <text><p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . - 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . - 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . - '<p>See Section 9 of S103 <em class="italic">Discovering ' . - 'Science</em> Block 8.</p></text> - </generalfeedback> - <defaultgrade>1</defaultgrade> - <penalty>0.33</penalty> - <hidden>0</hidden> - <shuffleanswers>0</shuffleanswers> - <shuffleanswers>false</shuffleanswers> - <answer> - <correctanswer>1</correctanswer> - <text>hydrogen</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>positive</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>hydroxide</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>negative</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>10<sup>7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>7</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>1</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>10<sup>-7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>greater</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>less</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <correctfeedback> - <text>Your answer is correct.</text> - </correctfeedback> - <correctresponsesfeedback>1</correctresponsesfeedback> - <partiallycorrectfeedback> - <text>Your answer is partially correct.</text> - </partiallycorrectfeedback> - <incorrectfeedback> - <text>Your answer is incorrect.</text> - </incorrectfeedback> - <unlimited>0</unlimited> - <penalty>0.33</penalty> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>0</clearincorrectresponses> - <hintcontent> - <text>You may wish to read Section 9 of <em ' . - 'class="italic">Discovering Science</em> Block 8.</text> - </hintcontent> - </hint> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>1</clearincorrectresponses> - <hintcontent> - <text>Any incorrect choices will be removed before your final try.</text> - </hintcontent> - </hint> - </question>'; - $xmldata = xmlize($xml); - - $importer = new qformat_xml(); - $q = $importer->try_importing_using_qtypes( - $xmldata['question'], null, null, 'ddwtos'); - - $expectedq = new stdClass(); - $expectedq->qtype = 'ddwtos'; - $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '<p>Drag and drop the words from the list below ' . - 'to fill the blank spaces and correctly complete the sentence.</p>' . - '<p>At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . - 'less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p>' . - '<!--DONOTCLEAN-->'; - $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '<p>At 25 °C all aqueous basic solutions ' . - 'have hydrogen ion concentrations less than 10<sup>−7</sup> ' . - 'mol litre<sup>−1</sup> and pH values greater than 7.</p><p>See ' . - 'Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>'; - $expectedq->defaultmark = 1; - $expectedq->length = 1; - $expectedq->penalty = 0.3333333; - - $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', - 'format' => FORMAT_HTML); - $expectedq->partiallycorrectfeedback = array( - 'text' => 'Your answer is partially correct.', - 'format' => FORMAT_HTML); - $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', - 'format' => FORMAT_HTML); - - $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - ); - - $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . - '<em class="italic">Discovering Science</em> Block 8.', - 'format' => FORMAT_HTML), - array('text' => 'Any incorrect choices will be removed before your final try.', - 'format' => FORMAT_HTML), - ); - $expectedq->hintshownumcorrect = array(true, true); - $expectedq->hintclearwrong = array(false, true); - - $this->assert(new question_check_specified_fields_expectation($expectedq), $q); - $this->assertEquals($expectedq->choices, $q->choices); - $this->assertEquals($expectedq->hint, $q->hint); - } - public function test_xml_export() { $qdata = new stdClass(); $qdata->id = 123;
cb8aefa658cfMDL-62880 qtype_ddwtos: drop support for legacy import format
2 files changed · +11 −219
question/type/ddwtos/questiontype.php+11 −26 modified@@ -71,32 +71,17 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu $question->shuffleanswers = $format->trans_single( $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1)); - if (!empty($data['#']['dragbox'])) { - // Modern XML format. - $dragboxes = $data['#']['dragbox']; - $question->answer = array(); - $question->draggroup = array(); - $question->infinite = array(); - - foreach ($data['#']['dragbox'] as $dragboxxml) { - $question->choices[] = array( - 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), - 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), - 'infinite' => array_key_exists('infinite', $dragboxxml['#']), - ); - } - - } else { - // Legacy format containing PHP serialisation. - foreach ($data['#']['answer'] as $answerxml) { - $ans = $format->import_answer($answerxml); - $options = unserialize(stripslashes($ans->feedback['text'])); - $question->choices[] = array( - 'answer' => $ans->answer, - 'choicegroup' => $options->draggroup, - 'infinite' => $options->infinite, - ); - } + // Import the choices. + $question->answer = array(); + $question->draggroup = array(); + $question->infinite = array(); + + foreach ($data['#']['dragbox'] as $dragboxxml) { + $question->choices[] = array( + 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true), + 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1), + 'infinite' => array_key_exists('infinite', $dragboxxml['#']), + ); } $format->import_combined_feedback($question, $data, true);
question/type/ddwtos/tests/questiontype_test.php+0 −193 modified@@ -243,199 +243,6 @@ public function test_xml_import() { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_import_legacy() { - $xml = ' <question type="ddwtos"> - <name> - <text>QDandD1 Base definition</text> - </name> - <questiontext format="html"> - <text><p>Drag and drop the words from the list below to fill the blank spaces ' . - 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . - 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . - 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . - '<!--DONOTCLEAN--></text> - </questiontext> - <image></image> - <generalfeedback> - <text><p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . - 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . - 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . - '<p>See Section 9 of S103 <em class="italic">Discovering ' . - 'Science</em> Block 8.</p></text> - </generalfeedback> - <defaultgrade>1</defaultgrade> - <penalty>0.33</penalty> - <hidden>0</hidden> - <shuffleanswers>0</shuffleanswers> - <shuffleanswers>false</shuffleanswers> - <answer> - <correctanswer>1</correctanswer> - <text>hydrogen</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>positive</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>hydroxide</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>negative</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>10<sup>7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>7</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>1</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>10<sup>-7</sup></text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>1</correctanswer> - <text>greater</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <answer> - <correctanswer>0</correctanswer> - <text>less</text> - <feedback> - <text>O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}</text> - </feedback> - </answer> - <correctfeedback> - <text>Your answer is correct.</text> - </correctfeedback> - <correctresponsesfeedback>1</correctresponsesfeedback> - <partiallycorrectfeedback> - <text>Your answer is partially correct.</text> - </partiallycorrectfeedback> - <incorrectfeedback> - <text>Your answer is incorrect.</text> - </incorrectfeedback> - <unlimited>0</unlimited> - <penalty>0.33</penalty> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>0</clearincorrectresponses> - <hintcontent> - <text>You may wish to read Section 9 of <em ' . - 'class="italic">Discovering Science</em> Block 8.</text> - </hintcontent> - </hint> - <hint> - <statenumberofcorrectresponses>1</statenumberofcorrectresponses> - <clearincorrectresponses>1</clearincorrectresponses> - <hintcontent> - <text>Any incorrect choices will be removed before your final try.</text> - </hintcontent> - </hint> - </question>'; - $xmldata = xmlize($xml); - - $importer = new qformat_xml(); - $q = $importer->try_importing_using_qtypes( - $xmldata['question'], null, null, 'ddwtos'); - - $expectedq = new stdClass(); - $expectedq->qtype = 'ddwtos'; - $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '<p>Drag and drop the words from the list below ' . - 'to fill the blank spaces and correctly complete the sentence.</p>' . - '<p>At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . - 'less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p>' . - '<!--DONOTCLEAN-->'; - $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '<p>At 25 °C all aqueous basic solutions ' . - 'have hydrogen ion concentrations less than 10<sup>−7</sup> ' . - 'mol litre<sup>−1</sup> and pH values greater than 7.</p><p>See ' . - 'Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>'; - $expectedq->defaultmark = 1; - $expectedq->length = 1; - $expectedq->penalty = 0.3333333; - - $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', - 'format' => FORMAT_HTML); - $expectedq->partiallycorrectfeedback = array( - 'text' => 'Your answer is partially correct.', - 'format' => FORMAT_HTML); - $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', - 'format' => FORMAT_HTML); - - $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_PLAIN), - 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '10<sup>7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10<sup>-7</sup>', 'format' => FORMAT_PLAIN), - 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_PLAIN), - 'choicegroup' => 3, 'infinite' => false), - ); - - $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . - '<em class="italic">Discovering Science</em> Block 8.', - 'format' => FORMAT_HTML), - array('text' => 'Any incorrect choices will be removed before your final try.', - 'format' => FORMAT_HTML), - ); - $expectedq->hintshownumcorrect = array(true, true); - $expectedq->hintclearwrong = array(false, true); - - $this->assert(new question_check_specified_fields_expectation($expectedq), $q); - $this->assertEquals($expectedq->choices, $q->choices); - $this->assertEquals($expectedq->hint, $q->hint); - } - public function test_xml_export() { $qdata = new stdClass(); $qdata->id = 123;
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
14- github.com/advisories/GHSA-c3pr-h96w-2jjgghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2018-14630ghsaADVISORY
- www.securityfocus.com/bid/105354mitrevdb-entryx_refsource_BID
- bugzilla.redhat.com/show_bug.cgighsax_refsource_CONFIRMWEB
- github.com/moodle/moodle/commit/09cbca8566a388e8f0a1a0cfd86cd0667088ed2cghsaWEB
- github.com/moodle/moodle/commit/be092b730910ad97fff0511e177a097ec1cc4b1cghsaWEB
- github.com/moodle/moodle/commit/cb8aefa658cf7ad8f002a480343afb2dea94cc08ghsaWEB
- github.com/moodle/moodle/commit/cfc4393aa689c277a27b9a040ff7dcbdac4e41ddghsaWEB
- github.com/moodle/moodle/commit/da1eeea0ff3d292b7669e478abc114872dd9cc8fghsaWEB
- moodle.org/mod/forum/discuss.phpghsax_refsource_CONFIRMWEB
- seclists.org/fulldisclosure/2018/Sep/28ghsamailing-listx_refsource_FULLDISCWEB
- web.archive.org/web/20200227111301/https://www.securityfocus.com/bid/105354ghsaWEB
- www.sec-consult.com/en/blog/advisories/remote-code-execution-php-unserialize-moodle-open-source-learning-platform-cve-2018-14630ghsaWEB
- www.sec-consult.com/en/blog/advisories/remote-code-execution-php-unserialize-moodle-open-source-learning-platform-cve-2018-14630/mitrex_refsource_MISC
News mentions
0No linked articles in our index yet.