MDL-4816 Short answer question type considers '100' and '100.' to be the same Actually, this may have affected other question types too.

This commit is contained in:
tjhunt
2006-08-23 21:17:23 +00:00
parent ac249da55e
commit c82f76d050
3 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -848,6 +848,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO
$actions[$quid]->timestamp = $time;
}
}
ksort($actions[$quid]->responses);
return $actions;
}
@@ -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
+1 -1
View File
@@ -841,7 +841,7 @@ class default_questiontype {
// 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;
}
/**
+1 -1
View File
@@ -188,7 +188,7 @@ class question_shortanswer_qtype extends default_questiontype {
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;
}