From fbcd38e669e8e34a6eda0ba7acd17f079483b4f7 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 7efe8bbb0d9b..df61c87a283d 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php @@ -1068,6 +1068,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 f3c265439604..e83ef3c70ebc 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php +++ b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php @@ -582,7 +582,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['question_type'] = $this->lng->txt($row['question_type']); + $row['question_type'] = $this->getQuestionTypeTranslation($row); $row['feedback'] = $row['feedback'] === 1; $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']); @@ -704,6 +704,22 @@ private function isActiveQuestionType(array $questionData): bool ->isActive(); } + private function getQuestionTypeTranslation(array $questionData): string + { + if (!($questionData['plugin'] ?? false)) { + return $this->lng->txt($questionData['question_type']); + } + + global $DIC; + foreach ($DIC['component.factory']->getActivePluginsInSlot('qst') as $plugin) { + if ($plugin->getQuestionType() === $questionData['question_type']) { + return $plugin->getQuestionTypeTranslation(); + } + } + + return $this->lng->txt($questionData['question_type']); + } + public function getDataArrayForQuestionId(int $questionId): array { return $this->questions[$questionId];