From 6a9a84c9904ec229120369cfd9cbdd05d86df6cd Mon Sep 17 00:00:00 2001 From: Philipp Imhof <52650214+PhilippImhof@users.noreply.github.com> Date: Fri, 17 Nov 2023 08:13:51 +0100 Subject: [PATCH] also catch evaluation error in grading var --- question.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/question.php b/question.php index 50cdb52e..22e66c62 100644 --- a/question.php +++ b/question.php @@ -708,8 +708,12 @@ public function grade_responses_individually($part, $response, &$checkunit, $for $this->add_special_correctness_variables($vars, $modelanswers, $coordinates, $dres->diff, $dres->is_number); // Step 7: Evaluate the grading variables and grading criteria to determine whether the answer is correct. - $vars = $this->qv->evaluate_assignments($vars, $part->vars2); + // Both steps can be in the same try-catch block, because upon validation, the grading vars + // are checked by another method and *before* the grading criterion. If they are invalid, + // the form validation stops therefore stops before validation the grading criterion and + // the error will not be linked to the wrong field. try { + $vars = $this->qv->evaluate_assignments($vars, $part->vars2); $correctness = $this->qv->evaluate_general_expression($vars, $part->correctness); } catch (Throwable $t) { // If the criterion cannot be evaluated (possible e.g. if the teacher uses part of the student's