MDL-66259 quiz responses: fix unrealistic test setup
authorTim Hunt <T.J.Hunt@open.ac.uk>
Sun, 29 Mar 2020 20:22:48 +0000 (21:22 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 24 Apr 2020 13:56:23 +0000 (15:56 +0200)
mod/quiz/report/responses/tests/fixtures/questions00.csv
mod/quiz/tests/attempt_walkthrough_from_csv_test.php

index 76c0bd2..bca9e72 100644 (file)
@@ -4,4 +4,4 @@ slot,type,which,cat,mark,overrides.hint.0.text,overrides.hint.0.format,overrides
 ,numerical,,rand,1,"Hint 1",0,"Hint 2",0,"Hint 3",0,"Hint 4",0,0
 2,calculatedsimple,sumwithvariants,maincat,1,"Hint 1",0,"Hint 2",0,"Hint 3",0,"Hint 4",0,0
 3,match,,maincat,1,"Hint 1",0,"Hint 2",0,"Hint 3",0,"Hint 4",0,0
-4,truefalse,,maincat,1,"Hint 1",0,"Hint 2",0,"Hint 3",0,"Hint 4",0,0
+4,truefalse,,maincat,1,"",0,"",0,"",0,"",0,0
index 0ec00de..dfaa1de 100644 (file)
@@ -94,6 +94,11 @@ class mod_quiz_attempt_walkthrough_from_csv_testcase extends advanced_testcase {
             if ($q['type'] !== 'random') {
                 // Don't actually create random questions here.
                 $overrides = array('category' => $cat->id, 'defaultmark' => $q['mark']) + $q['overrides'];
+                if ($q['type'] === 'truefalse') {
+                    // True/false question can never have hints, but sometimes we need to put them
+                    // in the CSV file, to keep it rectangular.
+                    unset($overrides['hint']);
+                }
                 $question = $questiongenerator->create_question($q['type'], $q['which'], $overrides);
                 $q['id'] = $question->id;