From 1332d805a2562811e4f4e4308ca637753d27f3fd Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Mon, 12 Jan 2026 14:55:34 +0100 Subject: [PATCH] Fixes error when exporting participant results including a formula question --- .../classes/class.assFormulaQuestion.php | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/components/ILIAS/TestQuestionPool/classes/class.assFormulaQuestion.php b/components/ILIAS/TestQuestionPool/classes/class.assFormulaQuestion.php index c3c8a7c44231..2b6709a8dc8b 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assFormulaQuestion.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assFormulaQuestion.php @@ -1400,17 +1400,23 @@ function (array $c, array $v): array { public function getCorrectSolutionForTextOutput(int $active_id, int $pass): array { - $best_solution = $this->getBestSolution($this->getSolutionValues($active_id, $pass)); - return array_map( - function (string $v) use ($best_solution): string { - $solution = "{$v} = {$best_solution[$v]['value']}"; - if (isset($best_solution['unit'])) { - $solution .= "{$this->unitrepository->getUnit($best_solution['unit'])->getUnit()}"; + $output = []; + + $best_solutions = $this->getBestSolution($this->getSolutionValues($active_id, $pass)); + foreach ($best_solutions as $key => $best_solution) { + $solution = "{$key} = " . ($best_solution['value'] ?? $best_solution); + + if (isset($best_solution['unit'])) { + $unit = $this->unitrepository->getUnit($best_solution['unit']); + if ($unit instanceof assFormulaQuestionUnit) { + $solution .= $unit->getUnit(); } - return $solution; - }, - array_keys($best_solution) - ); + } + + $output[$key] = $solution; + } + + return $output; } public function getVariablesAsTextArray(int $active_id, int $pass): array