From 9316d661217ac59f6ed903152c813f88faedbe79 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 9 Mar 2011 18:08:18 +0000 Subject: [PATCH] MDL-26714 qtype_multianswer needs an implementation of compare_responses. The main problem lack of this was causing is if you click through a quiz without answering any questions, mulitanswer questions would get marked as answered. --- question/type/multianswer/questiontype.php | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 012cc4314f0..00d66c92000 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -599,6 +599,37 @@ class embedded_cloze_qtype extends default_questiontype { echo ''; } + public function compare_responses($question, $state, $teststate) { + global $QTYPES; + + foreach ($question->options->questions as $key => $wrapped) { + if (empty($wrapped)) { + continue; + } + + $stateforquestion = clone($state); + if (isset($state->responses[$key])) { + $stateforquestion->responses[''] = $state->responses[$key]; + } else { + $stateforquestion->responses[''] = ''; + } + + $teststateforquestion = clone($teststate); + if (isset($teststate->responses[$key])) { + $teststateforquestion->responses[''] = $teststate->responses[$key]; + } else { + $teststateforquestion->responses[''] = ''; + } + + if (!$QTYPES[$wrapped->qtype]->compare_responses($wrapped, + $stateforquestion, $teststateforquestion)) { + return false; + } + } + + return true; + } + function grade_responses(&$question, &$state, $cmoptions) { global $QTYPES; $teststate = clone($state);