Skip to content

Commit

Permalink
MDL-4816 Short answer question type considers '100' and '100.' to be …
Browse files Browse the repository at this point in the history
…the same Actually, this may have affected other question types too.
  • Loading branch information
tjhunt committed Aug 23, 2006
1 parent ac249da commit c82f76d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/questionlib.php
Expand Up @@ -848,6 +848,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO
$actions[$quid]->timestamp = $time;
}
}
ksort($actions[$quid]->responses);
return $actions;
}

Expand Down Expand Up @@ -987,7 +988,7 @@ function question_process_responses(&$question, &$state, $action, $cmoptions, &$
// Check for unchanged responses (exactly unchanged, not equivalent).
// We also have to catch questions that the student has not yet attempted
$sameresponses = !$state->last_graded->event == QUESTION_EVENTOPEN &&
$state->responses == $action->responses;
$QTYPES[$question->qtype]->compare_responses($question, $action, $state);

// If the response has not been changed then we do not have to process it again
// unless the attempt is closing or validation is requested
Expand Down
2 changes: 1 addition & 1 deletion question/type/questiontype.php
Expand Up @@ -841,7 +841,7 @@ function compare_responses(&$question, $state, $teststate) {
// arrays. The ordering of the arrays does not matter.
// Question types may wish to override this (eg. to ignore trailing
// white space or to make "7.0" and "7" compare equal).
return $state->responses == $teststate->responses;
return $state->responses === $teststate->responses;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion question/type/shortanswer/questiontype.php
Expand Up @@ -188,7 +188,7 @@ function check_response(&$question, &$state) {
function compare_responses($question, $state, $teststate) {
if (isset($state->responses['']) && isset($teststate->responses[''])) {
if ($question->options->usecase) {
return $state->responses[''] == $teststate->responses[''];
return strcmp($state->responses[''], $teststate->responses['']) == 0;
} else {
return strcasecmp($state->responses[''], $teststate->responses['']) == 0;
}
Expand Down

0 comments on commit c82f76d

Please sign in to comment.