mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
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.
This commit is contained in:
parent
0226a97d31
commit
5276dc4887
@ -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;
|
||||
$grade = $potentialgrade;
|
||||
}
|
||||
} else {
|
||||
if ($answer->answer == $question->answer) {
|
||||
|
||||
} else if ($answer->answer == $question->answer) {
|
||||
$feedback[0] = $answer->feedback;
|
||||
$grade = (float)$answer->fraction * $question->grade;
|
||||
}
|
||||
$grade = $potentialgrade;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user