From bdb63d64f2625312ad7f7266ddaa59dc40103650 Mon Sep 17 00:00:00 2001 From: kaipe Date: Sun, 3 Aug 2003 20:02:43 +0000 Subject: [PATCH] Debugged question types NUMERICAL and MULTIANSWER (known as embedded answers) as these did not do things right whenever a student had not given any response (was treated as zero etc). For numerical there was also a need to allow typical shortanswer responses whenever there could be answers like n/a, inf, -inf, nan etc. Further more about numerical, there can be more than one answer alternative defined (just like for shortanswer). This is not supported by numerical.html but everywhere else. MULTIANSWER included, it is up to any taker to update numerical.html. This is more than likely to lead to overlappings between numerical ranges if more than one is defined. Think of the case where the highest grade answer ranges between 0 and 2 and the half grade answer ranges between 2 and 4. How should we grade 2? We should pick the highest grade! --- mod/quiz/lib.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 5064001b03..99f197f72e 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -784,25 +784,29 @@ function quiz_print_question($number, $question, $grade, $courseid, $actualresponse = $responseitems[1]; if (1.0 == $responsefractiongrade) { - $style = '"background-color:lime"'; + $style = 'style="background-color:lime"'; } else if (0.0 < $responsefractiongrade) { - $style = '"background-color:yellow"'; - } else { // The response must have been totally wrong: - $style = '"background-color:red"'; + $style = 'style="background-color:yellow"'; + } else if ('' != $actualresponse) { + // The response must have been totally wrong: + $style = 'style="background-color:red"'; + } else { + // There was no response given + $style = ''; } } else { $responsefractiongrade = 0.0; $actualresponse = ''; - $style = '"background-color:white"'; + $style = ''; } switch ($multianswer->answertype) { case SHORTANSWER: case NUMERICAL: - echo " "; + echo " "; break; case MULTICHOICE: - echo (" "); $answers = get_records_list("quiz_answers", "id", $multianswer->answers); echo (''); // Default empty option foreach ($answers as $answer) { @@ -1557,12 +1561,19 @@ function quiz_grade_attempt_question_result($question, $answers) { $correct[$answer->id] = $answer->answer; $bestshortanswer = $answer->fraction; } - if ( ((float)$question->answer >= (float)$answer->min) and - ((float)$question->answer <= (float)$answer->max) ) { + if ('' != $question->answer // Must not be mixed up with zero! + && (float)$answer->fraction > (float)$grade // Do we need to bother? + and // and has lower procedence than && and ||. + strtolower($question->answer) == strtolower($answer->answer) + || '' != trim($answer->min) + && ((float)$question->answer >= (float)$answer->min) + && ((float)$question->answer <= (float)$answer->max)) + { $feedback[0] = $answer->feedback; - $grade = (float)$answer->fraction * $question->grade; + $grade = (float)$answer->fraction; } } + $grade *= $question->grade; // Normalize to correct weight break; case TRUEFALSE: -- 2.39.5