]> git.mjollnir.org Git - moodle.git/commitdiff
When a teacher deletes a question that was already used as a random question in a...
authorgustav_delius <gustav_delius>
Sun, 30 Apr 2006 16:59:23 +0000 (16:59 +0000)
committergustav_delius <gustav_delius>
Sun, 30 Apr 2006 16:59:23 +0000 (16:59 +0000)
question/type/random/questiontype.php

index 194e035ab20ca6445f406e7fb1d31afcefe17441..93ab0f18792e4974e6f1a15cdbc69acce8fd377b 100644 (file)
@@ -129,7 +129,12 @@ class random_qtype extends default_questiontype {
             }
         } else {
             if (!$wrappedquestion = get_record('question', 'id', $answerregs[1])) {
-                return false;
+                // The teacher must have deleted this question by mistake
+                // Convert it into a description type question with an explanation to the student
+                $wrappedquestion = clone($question);
+                $wrappedquestion->id = $answerregs[1];
+                $wrappedquestion->questiontext = get_string('questiondeleted', 'quiz');
+                $wrappedquestion->qtype = 'description';
             }
             $state->responses[''] = (false === $answerregs[2]) ? '' : $answerregs[2];
         }