]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-6418 - Grading of multiple choice questions broken
authortjhunt <tjhunt>
Thu, 31 Aug 2006 16:59:05 +0000 (16:59 +0000)
committertjhunt <tjhunt>
Thu, 31 Aug 2006 16:59:05 +0000 (16:59 +0000)
question/type/multichoice/questiontype.php

index 63404e7801202353dd3785366870d814597f1a3e..82aafbf80c2395ccd7ad3d04d126e686258b215d 100644 (file)
@@ -339,34 +339,18 @@ class question_multichoice_qtype extends default_questiontype {
         include("$CFG->dirroot/question/type/multichoice/display.html");
     }
 
+    
+
     function grade_responses(&$question, &$state, $cmoptions) {
-        $answers      = $question->options->answers;
-        $testedstate = clone($state);
-        $teststate    = clone($state);
-        $state->raw_grade = 0;
-        foreach($answers as $answer) {
-            $teststate->responses = array('' => $answer->id);
-            if($question->options->single) {
-                if($this->compare_responses($question, $testedstate,
-                 $teststate)) {
-                    $state->raw_grade = $answer->fraction;
-                    break;
-                }
-            } else {
-                foreach($state->responses as $response) {
-                    $testedstate->responses = array('' => $response);
-                    if($this->compare_responses($question, $testedstate,
-                     $teststate)) {
-                        $state->raw_grade += $answer->fraction;
-                         break;
-                    }
-                }
-            }
-        }
-        if (empty($state->raw_grade)) {
+        if($question->options->single) {
+            $state->raw_grade = $question->options->answers[reset($state->responses)]->fraction;
+        } else {
             $state->raw_grade = 0;
+            foreach ($state->responses as $response) {
+                $state->raw_grade += $question->options->answers[$response]->fraction;
+            }
         }
-
+                
         // 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;