Permalink
Browse files

Bug Fix: The code for dealing with the * character for shortanswer qu…

…estion type was lost. I downloaded 1.4.5+ and merged the shortanswer grading code into 1.6 dev.
  • Loading branch information...
1 parent 1a08f75 commit 0719af8aacf549269402aaf8eadbe842c1a38e47 michaelpenne committed Jun 21, 2005
Showing with 16 additions and 26 deletions.
  1. +16 −26 mod/lesson/action/continue.php
@@ -134,58 +134,48 @@
}
$useranswer = stripslashes(clean_param($useranswer, PARAM_CLEAN));
$userresponse = addslashes($useranswer);
-
+
if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
error("Continue: No answers found");
}
+
foreach ($answers as $answer) {
- /// CDC-FLAG ///
- if ($lesson->custom && $answer->score > 0) {
+ // massage the wild cards (if present)
+ if (strpos(' '.$answer->answer, '*')) {
+ $answer->answer = str_replace('\*','@@@@@@', $answer->answer);
+ $answer->answer = str_replace('*','.*', $answer->answer);
+ $answer->answer = str_replace('@@@@@@', '\*', $answer->answer);
+ $answer->answer = str_replace('+', '\+', $answer->answer);
+ }
+ if (lesson_iscorrect($pageid, $answer->jumpto) or
+ ($lesson->custom && $answer->score > 0) ) {
if ($page->qoption) {
// case sensitive
- if ($answer->answer == $useranswer) {
+ if (ereg('^'.$answer->answer.'$', $useranswer)) {
$correctanswer = true;
$answerid = $answer->id;
$newpageid = $answer->jumpto;
if (trim(strip_tags($answer->response))) {
$response = $answer->response;
}
+ break;
}
} else {
// case insensitive
- if (strcasecmp($answer->answer, $useranswer) == 0) {
+ if (eregi('^'.$answer->answer.'$', $useranswer)) {
$correctanswer = true;
$answerid = $answer->id;
$newpageid = $answer->jumpto;
if (trim(strip_tags($answer->response))) {
$response = $answer->response;
}
- }
- }
- } elseif (lesson_iscorrect($pageid, $answer->jumpto) && !$lesson->custom) { /// CDC-FLAG 6/21/04 ///
- if ($page->qoption) {
- // case sensitive
- if ($answer->answer == $useranswer) {
- $correctanswer = true;
- $newpageid = $answer->jumpto;
- if (trim(strip_tags($answer->response))) {
- $response = $answer->response;
- }
- }
- } else {
- // case insensitive
- if (strcasecmp($answer->answer, $useranswer) == 0) {
- $correctanswer = true;
- $newpageid = $answer->jumpto;
- if (trim(strip_tags($answer->response))) {
- $response = $answer->response;
- }
+ break;
}
}
} else {
// see if user typed in any of the wrong answers
// don't worry about case
- if (strcasecmp($answer->answer, $useranswer) == 0) {
+ if (eregi('^'.$answer->answer.'$', $useranswer)) {
$newpageid = $answer->jumpto;
$answerid = $answer->id;
if (trim(strip_tags($answer->response))) {

0 comments on commit 0719af8

Please sign in to comment.