From 4572d78f71a13becface8824b7f91308fa12b400 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sun, 30 Apr 2006 16:59:23 +0000 Subject: [PATCH] When a teacher deletes a question that was already used as a random question in a quiz the student now gets a useful message about the fact rather than just a php error. --- question/type/random/questiontype.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index 194e035ab2..93ab0f1879 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -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]; } -- 2.39.5