From 511952b9eeeeb0b3937e562e3fdceb5f4984912e Mon Sep 17 00:00:00 2001 From: Stephan Kergomard Date: Fri, 3 Jan 2025 11:47:52 +0200 Subject: [PATCH] Test: Fix Access To Function on Null in Eval See: https://mantis.ilias.de/view.php?id=43300 --- .../class.ilTestEvaluationFactory.php | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/components/ILIAS/Test/classes/Evaluation/class.ilTestEvaluationFactory.php b/components/ILIAS/Test/classes/Evaluation/class.ilTestEvaluationFactory.php index 0c2c4423aad6..1998fb918b28 100644 --- a/components/ILIAS/Test/classes/Evaluation/class.ilTestEvaluationFactory.php +++ b/components/ILIAS/Test/classes/Evaluation/class.ilTestEvaluationFactory.php @@ -306,22 +306,27 @@ private function addMarksToParticipants(ilTestEvaluationData $evaluation_data): foreach ($evaluation_data->getParticipantIds() as $active_id) { $user_eval_data = $evaluation_data->getParticipant($active_id); - $percentage = $user_eval_data->getReachedPointsInPercent(); - $mark = $mark_schema->getMatchingMark($percentage); - - if ($mark !== null) { - $user_eval_data->setMark($mark); - for ($i = 0;$i < $user_eval_data->getPassCount();$i++) { - $pass_data = $user_eval_data->getPass($i); - $mark = $mark_schema->getMatchingMark( - $pass_data->getReachedPointsInPercent() - ); - if ($mark !== null) { - $pass_data->setMark($mark); - } - } + $mark = $mark_schema->getMatchingMark( + $user_eval_data->getReachedPointsInPercent() + ); + + if ($mark === null) { + continue; } + $user_eval_data->setMark($mark); + for ($i = 0; $i < $user_eval_data->getPassCount(); $i++) { + $pass_data = $user_eval_data->getPass($i); + if ($pass_data === null) { + continue; + } + $mark = $mark_schema->getMatchingMark( + $pass_data->getReachedPointsInPercent() + ); + if ($mark !== null) { + $pass_data->setMark($mark); + } + } } return $evaluation_data;