Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Short-answer fixes:

As the wild card feature makes it possible for a response to match more than one answer alternative, I made sure that the alternative with the
highest grade would count.
I also fixed bug #945 for the short answer case.
  • Loading branch information...
commit 5276dc48877ffb57855f394b762915f204a49205 1 parent 0226a97
kaipe authored
Showing with 12 additions and 11 deletions.
  1. +12 −11 mod/quiz/lib.php
View
23 mod/quiz/lib.php
@@ -1613,31 +1613,32 @@ function quiz_grade_attempt_question_result($question,
$question->answer = "";
}
$response[0] = $question->answer;
- $bestshortanswer = 0;
+ $feedback[0] = ''; // Default
foreach ($answers as $answer) { // There might be multiple right answers
$answer->answer = trim($answer->answer); // Just in case
- if ($answer->fraction > $bestshortanswer) {
- $correct[$answer->id] = $answer->answer;
- $bestshortanswer = $answer->fraction;
+ if ($answer->fraction >= 1.0) {
+ $correct[] = $answer->answer;
}
if (!$answer->usecase) { // Don't compare case
$answer->answer = strtolower($answer->answer);
$question->answer = strtolower($question->answer);
}
- if ((strpos(' '.$answer->answer, '*'))) {
+ $potentialgrade = (float)$answer->fraction * $question->grade;
+
+ if ($potentialgrade >= $grade
+ and (strpos(' '.$answer->answer, '*'))) {
$answer->answer = eregi_replace('\*','.*',$answer->answer);
if (eregi('^'.$answer->answer.'$', $question->answer)) {
$feedback[0] = $answer->feedback;
- $grade = (float)$answer->fraction * $question->grade;
- }
- } else {
- if ($answer->answer == $question->answer) {
- $feedback[0] = $answer->feedback;
- $grade = (float)$answer->fraction * $question->grade;
+ $grade = $potentialgrade;
}
+
+ } else if ($answer->answer == $question->answer) {
+ $feedback[0] = $answer->feedback;
+ $grade = $potentialgrade;
}
}
break;
Please sign in to comment.
Something went wrong with that request. Please try again.