From e723ae88f4e4e7148dc09e7e11feb7a7e2ef4c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= Date: Wed, 3 Jun 2026 12:05:14 +0200 Subject: [PATCH] [FIX] TestQuestionPool: Translate plugin question types --- .../classes/class.assQuestionGUI.php | 11 +++++++++++ .../classes/class.ilAssQuestionList.php | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php index 276d500882b6..0959fdc71152 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php @@ -1063,6 +1063,17 @@ public function outQuestionType(): string } } + return $this->getQuestionTypeTranslation(); + } + + private function getQuestionTypeTranslation(): string + { + $question_properties = $this->questionrepository->getForQuestionId($this->object->getId()); + $type_name = $question_properties?->getTypeName($this->lng); + if ($type_name !== null && $type_name !== '') { + return $type_name; + } + return $this->lng->txt($this->object->getQuestionType()); } diff --git a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php index 8e499dc1dcd0..8599deff1e51 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php +++ b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php @@ -603,7 +603,7 @@ public function load(): void $row['description'] = $tags_trafo->transform($row['description'] ?? ''); $row['author'] = $tags_trafo->transform($row['author']); $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['obj_fi'], $row['question_id']); - $row['ttype'] = $this->lng->txt($row['type_tag']); + $row['ttype'] = $this->getQuestionTypeTranslation($row); $row['feedback'] = $row['feedback'] === 1; $row['hints'] = $row['hints'] === 1; $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']); @@ -699,6 +699,22 @@ private function isActiveQuestionType(array $questionData): bool ->isActive(); } + private function getQuestionTypeTranslation(array $questionData): string + { + if (!($questionData['plugin'] ?? false)) { + return $this->lng->txt($questionData['type_tag']); + } + + global $DIC; + foreach ($DIC['component.factory']->getActivePluginsInSlot('qst') as $plugin) { + if ($plugin->getQuestionType() === $questionData['type_tag']) { + return $plugin->getQuestionTypeTranslation(); + } + } + + return $this->lng->txt($questionData['type_tag']); + } + public function getDataArrayForQuestionId(int $questionId) { return $this->questions[$questionId];