Skip to content

Commit

Permalink
separately catch evaluation error in grading var
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippImhof committed Nov 17, 2023
1 parent ef913f7 commit e007c42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion question.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e007c42

Please sign in to comment.