From: pichetp Date: Fri, 11 Jan 2008 14:24:10 +0000 (+0000) Subject: MDL12932 -Random Short-Answer Matching does not display correctly in Item analysis... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fa1661c27c6e66423d2614fe154284f4b0ba6c38;p=moodle.git MDL12932 -Random Short-Answer Matching does not display correctly in Item analysis report --- diff --git a/mod/quiz/report/analysis/report.php b/mod/quiz/report/analysis/report.php index 81db91eb6d..bf579faf6c 100644 --- a/mod/quiz/report/analysis/report.php +++ b/mod/quiz/report/analysis/report.php @@ -154,6 +154,9 @@ class quiz_report extends quiz_default_report { continue; } $qtype = ($quizquestions[$i]->qtype=='random') ? $states[$i]->options->question->qtype : $quizquestions[$i]->qtype; + if($quizquestions[$i]->qtype =='randomsamatch'){ + $quizquestions[$i]->options =$states[$i]->options ; + } $q = get_question_responses($quizquestions[$i], $states[$i]); if (empty($q)){ continue; diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index fb4a8306dc..e6fbee99fe 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -246,6 +246,26 @@ class question_randomsamatch_qtype extends question_match_qtype { "AND hidden = '0'" . "AND id NOT IN ($questionsinuse)"); } + function get_all_responses($question, $state) { + $answers = array(); + if (is_array($question->options->subquestions)) { + foreach ($question->options->subquestions as $aid => $answer) { + if ($answer->questiontext) { + foreach($answer->options->answers as $ans ){ + $answer->answertext = $ans->answer ; + } + $r = new stdClass; + $r->answer = $answer->questiontext . ": " . $answer->answertext; + $r->credit = 1; + $answers[$aid] = $r; + } + } + } + $result = new stdClass; + $result->id = $question->id; + $result->responses = $answers; + return $result; + } /// BACKUP FUNCTIONS ////////////////////////////