]> git.mjollnir.org Git - moodle.git/commitdiff
Fix problem with multichoice question grading. Merged from MOODLE_17_STABLE.
authortjhunt <tjhunt>
Thu, 19 Oct 2006 11:54:17 +0000 (11:54 +0000)
committertjhunt <tjhunt>
Thu, 19 Oct 2006 11:54:17 +0000 (11:54 +0000)
question/type/multichoice/questiontype.php

index c22d5ba629ed6cd2ed769d4cd6c51a3094c20442..01b2bc64faf75bb14acbd572fb7a1b4ba52c61e4 100644 (file)
@@ -339,15 +339,19 @@ class question_multichoice_qtype extends default_questiontype {
         include("$CFG->dirroot/question/type/multichoice/display.html");
     }
 
-    
-
     function grade_responses(&$question, &$state, $cmoptions) {
         if($question->options->single) {
-            $state->raw_grade = $question->options->answers[reset($state->responses)]->fraction;
+            $response = reset($state->responses);
+            if ($response) {
+                $state->raw_grade = $question->options->answers[$response]->fraction;
+            } else {
+                $state->raw_grade = 0;
+            }
         } else {
-            $state->raw_grade = 0;
             foreach ($state->responses as $response) {
-                $state->raw_grade += $question->options->answers[$response]->fraction;
+                if ($response) {
+                    $state->raw_grade += $question->options->answers[$response]->fraction;
+                }
             }
         }