From acd48843a9e2b16796c44522b3f8204a846c10e4 Mon Sep 17 00:00:00 2001 From: mindforge Date: Thu, 8 Sep 2005 18:13:19 +0000 Subject: [PATCH] Merged from 1.5 stable --- .../questiontypes/randomsamatch/questiontype.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mod/quiz/questiontypes/randomsamatch/questiontype.php b/mod/quiz/questiontypes/randomsamatch/questiontype.php index 61bc778a54d..1cc58ace572 100644 --- a/mod/quiz/questiontypes/randomsamatch/questiontype.php +++ b/mod/quiz/questiontypes/randomsamatch/questiontype.php @@ -182,6 +182,20 @@ class quiz_randomsamatch_qtype extends quiz_match_qtype { notify("Couldn't get question options (id=$response[0])!"); return false; } + + // Now we overwrite the $question->options->answers field to only + // *one* (the first) correct answer. This loop can be deleted to + // take all answers into account (i.e. put them all into the + // drop-down menu. + $foundcorrect = false; + foreach ($wrappedquestion->options->answers as $answer) { + if ($foundcorrect || $answer->fraction != 1.0) { + unset($wrappedquestion->options->answers[$answer->id]); + } else if (!$foundcorrect) { + $foundcorrect = true; + } + } + if (!$QUIZ_QTYPES[$wrappedquestion->qtype] ->restore_session_and_responses($wrappedquestion, $state)) { notify("Couldn't restore session of question (id=$response[0])!");