Permalink
Browse files

Some preliminary code to allow wildcards in short answers.

Based on code sent by Thomas Robb
  • Loading branch information...
1 parent 3fcc331 commit 0ce4aa1a8a381f2014d46e6ee5b04db1bdef8e23 moodler committed Dec 29, 2003
Showing with 12 additions and 3 deletions.
  1. +12 −3 mod/quiz/lib.php
View
@@ -1623,9 +1623,18 @@ function quiz_grade_attempt_question_result($question,
$answer->answer = strtolower($answer->answer);
$question->answer = strtolower($question->answer);
}
- if ($question->answer == $answer->answer) {
- $feedback[0] = $answer->feedback;
- $grade = (float)$answer->fraction * $question->grade;
+
+ if ((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;
+ }
}
}
break;

0 comments on commit 0ce4aa1

Please sign in to comment.