Permalink
Browse files

MDL-26714 qtype_multianswer needs an implementation of compare_respon…

…ses.

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.
  • Loading branch information...
1 parent c096042 commit 9316d661217ac59f6ed903152c813f88faedbe79 @timhunt timhunt committed Mar 9, 2011
Showing with 31 additions and 0 deletions.
  1. +31 −0 question/type/multianswer/questiontype.php
@@ -599,6 +599,37 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
echo '</div>';
}
+ 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);

0 comments on commit 9316d66

Please sign in to comment.