From c82f76d0502a9120314d8e764330bfec0742777e Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 23 Aug 2006 21:17:23 +0000 Subject: [PATCH] MDL-4816 Short answer question type considers '100' and '100.' to be the same Actually, this may have affected other question types too. --- lib/questionlib.php | 3 ++- question/type/questiontype.php | 2 +- question/type/shortanswer/questiontype.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index 831bea14b6..27989ebd04 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -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 diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 858d5901e2..ee2f8dfe78 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -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; } /** diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index a2e4e90d6c..07ae2e3d96 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -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; } -- 2.39.5