From 2958e18586b7d1cfa603f513afe60a8d347f1bb7 Mon Sep 17 00:00:00 2001 From: gbateson Date: Mon, 15 Oct 2007 01:00:38 +0000 Subject: [PATCH] where the correct responses on a JQuiz multiple choice question all have a score of 0%, the scores will be corrected to 100% --- question/format/hotpot/format.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/question/format/hotpot/format.php b/question/format/hotpot/format.php index b08f0218a8..d3fd3119ec 100644 --- a/question/format/hotpot/format.php +++ b/question/format/hotpot/format.php @@ -420,6 +420,9 @@ class qformat_hotpot extends qformat_default { $question->answer = array(); $question->fraction = array(); $question->feedback = array(); + $aa = 0; + $correct_answers = array(); + $correct_answers_all_zero = true; while (($answer = $answers."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) { $correct = $xml->xml_value($tags, $answer."['correct'][0]['#']"); if (empty($correct)) { @@ -439,12 +442,26 @@ class qformat_hotpot extends qformat_default { } $answertext = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['text'][0]['#']")); if ($answertext!='') { - $question->answer[] = $answertext; - $question->fraction[] = $fraction; - $question->feedback[] = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']")); + $question->answer[$aa] = $answertext; + $question->fraction[$aa] = $fraction; + $question->feedback[$aa] = $this->hotpot_prepare_str($xml->xml_value($tags, $answer."['feedback'][0]['#']")); + if ($correct) { + if ($fraction) { + $correct_answers_all_zero = false; + } + $correct_answers[] = $aa; + } + $aa++; } $a++; } + if ($correct_answers_all_zero) { + // correct answers all have score of 0%, + // so reset score for correct answers 100% + foreach ($correct_answers as $aa) { + $question->fraction[$aa] = 1; + } + } $questions[] = $question; $q++; } -- 2.39.5