MDL-47494 gapselect: Question import, support for files in hints.
Also fix some minor bugs and unit tests.
This commit is contained in:
@@ -77,7 +77,7 @@ class qtype_gapselect extends qtype_gapselect_base {
|
||||
foreach ($data['#']['selectoption'] as $selectoptionxml) {
|
||||
$question->choices[] = array(
|
||||
'answer' => $format->getpath($selectoptionxml, array('#', 'text', 0, '#'), '', true),
|
||||
'selectgroup' => $format->getpath($selectoptionxml, array('#', 'group', 0, '#'), 1),
|
||||
'choicegroup' => $format->getpath($selectoptionxml, array('#', 'group', 0, '#'), 1),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class qtype_gapselect extends qtype_gapselect_base {
|
||||
$ans = $format->import_answer($answerxml);
|
||||
$question->choices[] = array(
|
||||
'answer' => $ans->answer,
|
||||
'selectgroup' => $ans->feedback,
|
||||
'choicegroup' => $ans->feedback,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,16 +214,19 @@ class qtype_gapselect_test extends UnitTestCase {
|
||||
$expectedq->incorrectfeedback = array('text' => '<p>Your answer is incorrect.</p>', 'format' => FORMAT_MOODLE, 'files' => array());
|
||||
|
||||
$expectedq->choices = array(
|
||||
array('answer' => 'Alpha', 'selectgroup' => 1),
|
||||
array('answer' => 'Beta', 'selectgroup' => 1),
|
||||
array('answer' => 'Gamma', 'selectgroup' => 1),
|
||||
array('answer' => 'Alpha', 'choicegroup' => 1),
|
||||
array('answer' => 'Beta', 'choicegroup' => 1),
|
||||
array('answer' => 'Gamma', 'choicegroup' => 1),
|
||||
);
|
||||
|
||||
$expectedq->hint = array('Try again.', 'These are the first three letters of the Greek alphabet.');
|
||||
$expectedq->hint = array(
|
||||
array('text' => 'Try again.', 'format' => FORMAT_MOODLE, 'files' => array()),
|
||||
array('text' => 'These are the first three letters of the Greek alphabet.', 'format' => FORMAT_MOODLE, 'files' => array()));
|
||||
$expectedq->hintshownumcorrect = array(true, true);
|
||||
$expectedq->hintclearwrong = array(false, true);
|
||||
|
||||
$this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
|
||||
$this->assertEqual($expectedq->hint, $q->hint);
|
||||
}
|
||||
|
||||
public function test_xml_export() {
|
||||
|
||||
Reference in New Issue
Block a user