]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-4816 Short answer question type considers '100' and '100.' to be the same\r\rActual...
authortjhunt <tjhunt>
Wed, 23 Aug 2006 21:17:23 +0000 (21:17 +0000)
committertjhunt <tjhunt>
Wed, 23 Aug 2006 21:17:23 +0000 (21:17 +0000)
lib/questionlib.php
question/type/questiontype.php
question/type/shortanswer/questiontype.php

index 831bea14b6f005bcafba5d83a6b597f055b9f778..27989ebd0453041dd934ec16f5dace1ad8af0b77 100644 (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
index 858d5901e26813de6860877005404749f2ebdaef..ee2f8dfe784980e18a2945c9696ef8999249899a 100644 (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;
     }
 
     /**
index a2e4e90d6ce2bf1201f7e418301a09c96c00fdd6..07ae2e3d964fd26583aecfca0bb76a9e57221a81 100644 (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;
             }