From fe7e43f43044cc072bcf381cd4016f7b5979a270 Mon Sep 17 00:00:00 2001 From: pichetp Date: Tue, 13 Oct 2009 01:02:30 +0000 Subject: [PATCH] MDL-20296 setting get_correct_responses() for calculated regular and multichoice --- question/type/calculated/questiontype.php | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index 2c62d7acf71..40d329733e8 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -1425,19 +1425,29 @@ class question_calculated_qtype extends default_questiontype { function get_correct_responses(&$question, &$state) { $virtualqtype = $this->get_virtual_qtype( $question); - if($unit = $virtualqtype->get_default_numerical_unit($question)){ - $unit = $unit->unit; - } else { - $unit = ''; - } - foreach ($question->options->answers as $answer) { - if (((int) $answer->fraction) === 1) { - $answernumerical = qtype_calculated_calculate_answer( - $answer->answer, $state->options->dataset, $answer->tolerance, - $answer->tolerancetype, $answer->correctanswerlength, - $answer->correctanswerformat, $unit); - return array('' => $answernumerical->answer); + if ($question->options->multichoice != 1 ) { + if($unit = $virtualqtype->get_default_numerical_unit($question)){ + $unit = $unit->unit; + } else { + $unit = ''; } + foreach ($question->options->answers as $answer) { + if (((int) $answer->fraction) === 1) { + $answernumerical = qtype_calculated_calculate_answer( + $answer->answer, $state->options->dataset, $answer->tolerance, + $answer->tolerancetype, $answer->correctanswerlength, + $answer->correctanswerformat, ''); // remove unit + $correct = array('' => $answernumerical->answer); + $correct['answer']= $correct['']; + if (isset($correct['']) && $correct[''] != '*' && $unit ) { + $correct[''] .= ' '.$unit; + $correct['unit']= $unit; + } + return $correct; + } + } + }else{ + return $virtualqtype->get_correct_responses($question, $state) ; } return null; }