From: gustav_delius Date: Thu, 6 Apr 2006 16:43:41 +0000 (+0000) Subject: Jean-Michel's fix to the get_actual_responses() method X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=01bd54e0cbee923deb2ab32e2c0bfcfe94b72009;p=moodle.git Jean-Michel's fix to the get_actual_responses() method --- diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 5e9be61862..d8cb0602cf 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -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