Skip to content

Commit

Permalink
Bug Fix: The code for dealing with the * character for shortanswer qu…
Browse files Browse the repository at this point in the history
…estion type was lost. I downloaded 1.4.5+ and merged the shortanswer grading code into 1.6 dev.
  • Loading branch information
michaelpenne committed Jun 21, 2005
1 parent 1a08f75 commit 0719af8
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions mod/lesson/action/continue.php
Expand Up @@ -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))) {
Expand Down

0 comments on commit 0719af8

Please sign in to comment.