Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 9316d661217ac59f6ed903152c813f88faedbe79 1 parent c096042
@timhunt timhunt authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 question/type/multianswer/questiontype.php
View
31 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);
Please sign in to comment.
Something went wrong with that request. Please try again.