Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

where the correct responses on a JQuiz multiple choice question all h…

…ave a score of 0%, the scores will be corrected to 100%
  • Loading branch information...
commit 4ad794c52403d86593160b03e27dccc4e6751d31 1 parent 4aec47a
gbateson authored
Showing with 20 additions and 3 deletions.
  1. +20 −3 question/format/hotpot/format.php
View
23 question/format/hotpot/format.php
@@ -416,6 +416,9 @@ function process_jquiz(&$xml, &$questions) {
$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)) {
@@ -435,12 +438,26 @@ function process_jquiz(&$xml, &$questions) {
}
$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++;
}
Please sign in to comment.
Something went wrong with that request. Please try again.