]> git.mjollnir.org Git - moodle.git/commitdiff
Jean-Michel's fix to the get_actual_responses() method
authorgustav_delius <gustav_delius>
Thu, 6 Apr 2006 16:43:41 +0000 (16:43 +0000)
committergustav_delius <gustav_delius>
Thu, 6 Apr 2006 16:43:41 +0000 (16:43 +0000)
question/type/match/questiontype.php

index 5e9be61862ee060f75b2cbf44f700dbbeea3c7bd..d8cb0602cf1d0b9063fcb108de85acd628bc9ea3 100644 (file)
@@ -322,18 +322,18 @@ class question_match_qtype extends default_questiontype {
 
     // ULPGC ecastro
     function get_actual_response($question, $state) {
-        unset($results);
-        if (isset($state->responses)) {
-            foreach($state->responses as $left=>$right){
-                $lpair = $question->options->subquestions[$left]->questiontext;
-                $rpair = $right ? $question->options->subquestions[$right]->answertext : '';
-                $results[$left] = $lpair." : ".$rpair;
-            }
-            return $results;
-        } else {
-            return null;
-        }
-    }
+       $subquestions = &$state->options->subquestions;
+       $responses    = &$state->responses;
+       $results=array();
+       foreach ($subquestions as $key => $sub) {
+           foreach ($responses as $ind => $code) {
+               if (isset($sub->options->answers[$code])) {
+                   $results[$ind] =  $subquestions[$ind]->questiontext . " : " . $sub->options->answers[$code]->answer;
+               }
+           }
+       }
+       return $results;
+   }
 
     function response_summary($question, $state, $length=80) {
         // This should almost certainly be overridden