MDL-47494 gapselect: Question import, support for files in hints.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 23 Mar 2011 14:27:22 +0000 (14:27 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 23 Mar 2011 14:27:22 +0000 (14:27 +0000)
Also fix some minor bugs and unit tests.

question/type/gapselect/questiontype.php
question/type/gapselect/simpletest/testquestiontype.php

index dd27431..8bc86c6 100755 (executable)
@@ -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,
                 );
             }
         }
index 336621b..be8a5b5 100755 (executable)
@@ -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() {