Revert "MDL-33105 flexible apply_units() function"
[moodle.git] / question / type / numerical / question.php
index 2e39db1..0e48155 100644 (file)
@@ -106,6 +106,10 @@ class qtype_numerical_question extends question_graded_automatically {
             return false;
         }
 
+        if ($this->ap->contains_thousands_seaparator($response['answer'])) {
+            return false;
+        }
+
         return true;
     }
 
@@ -127,6 +131,11 @@ class qtype_numerical_question extends question_graded_automatically {
             return get_string('unitnotselected', 'qtype_numerical');
         }
 
+        if ($this->ap->contains_thousands_seaparator($response['answer'])) {
+            return get_string('pleaseenteranswerwithoutthousandssep', 'qtype_numerical',
+                    $this->ap->get_separator());
+        }
+
         return '';
     }
 
@@ -278,7 +287,7 @@ class qtype_numerical_question extends question_graded_automatically {
             list($value, $unit, $multiplier) = $this->ap->apply_units(
                     $currentanswer, $selectedunit);
             $answer = $this->get_matching_answer($value, $multiplier);
-            $answerid = reset($args); // Itemid is answer id.
+            $answerid = reset($args); // itemid is answer id.
             return $options->feedback && $answer && $answerid == $answer->id;
 
         } else if ($component == 'question' && $filearea == 'hint') {