MDL-46148 qtype_calculatedsimple: fix notice
authorTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 9 Jul 2014 12:47:40 +0000 (13:47 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 9 Jul 2014 12:47:48 +0000 (13:47 +0100)
... when adding a dataset with a formula error.

question/type/calculated/questiontype.php

index 84faed8..b75057b 100644 (file)
@@ -1061,10 +1061,14 @@ class qtype_calculated extends question_type {
         }
 
         $answers = fullclone($answers);
-        $errors = '';
         $delimiter = ': ';
         $virtualqtype =  $qtypeobj->get_virtual_qtype();
         foreach ($answers as $key => $answer) {
+            $error = qtype_calculated_find_formula_errors($answer->answer);
+            if ($error) {
+                $comment->stranswers[$key] = $error;
+                continue;
+            }
             $formula = $this->substitute_variables($answer->answer, $data);
             $formattedanswer = qtype_calculated_calculate_answer(
                 $answer->answer, $data, $answer->tolerance,