]> git.mjollnir.org Git - moodle.git/commitdiff
Fix multiple-choice multiple-answer grading code. Merged from MOODLE_17_STABLE.
authortjhunt <tjhunt>
Tue, 16 Jan 2007 17:51:05 +0000 (17:51 +0000)
committertjhunt <tjhunt>
Tue, 16 Jan 2007 17:51:05 +0000 (17:51 +0000)
question/type/multichoice/questiontype.php

index cfa9bee52a9039382eeae22a62f0e62f9991e8d4..fda824f50be8c2738044399597973abf0baf0769 100644 (file)
@@ -346,12 +346,11 @@ class question_multichoice_qtype extends default_questiontype {
     }
 
     function grade_responses(&$question, &$state, $cmoptions) {
+        $state->raw_grade = 0;
         if($question->options->single) {
             $response = reset($state->responses);
             if ($response) {
                 $state->raw_grade = $question->options->answers[$response]->fraction;
-            } else {
-                $state->raw_grade = 0;
             }
         } else {
             foreach ($state->responses as $response) {
@@ -360,10 +359,11 @@ class question_multichoice_qtype extends default_questiontype {
                 }
             }
         }
-                
+
         // Make sure we don't assign negative or too high marks
         $state->raw_grade = min(max((float) $state->raw_grade,
                             0.0), 1.0) * $question->maxgrade;
+
         // Apply the penalty for this attempt
         $state->penalty = $question->penalty * $question->maxgrade;