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:
+2
-1
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user