From 20af9d3c0f4cd1925802db5079246ee4b624ebe8 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 9 Jul 2014 13:47:40 +0100 Subject: [PATCH] MDL-46148 qtype_calculatedsimple: fix notice ... when adding a dataset with a formula error. --- question/type/calculated/questiontype.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index 4d22123f917..18d945bbf9a 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -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,