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 1/3] [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]; From e51beb8ce1210f1f877e2582de00e4b387724b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= Date: Tue, 9 Jun 2026 15:05:52 +0200 Subject: [PATCH 2/3] [FIX] TestQuestionPool: Use snake_case and move DIC usage to constructor --- .../classes/class.ilAssQuestionList.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php index 8599deff1e51..d7046c9e6df0 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php +++ b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php @@ -74,6 +74,8 @@ class ilAssQuestionList implements ilTaxAssignedItemInfo private ?Order $order = null; private ?Range $range = null; + private ilComponentFactory $component_factory; + public function __construct( private ilDBInterface $db, private ilLanguage $lng, @@ -81,6 +83,8 @@ public function __construct( private ilComponentRepository $component_repository, private ?NotesService $notes_service = null ) { + global $DIC; + $this->component_factory = $DIC['component.factory']; } public function setOrder(?Order $order = null): void @@ -699,20 +703,19 @@ private function isActiveQuestionType(array $questionData): bool ->isActive(); } - private function getQuestionTypeTranslation(array $questionData): string + private function getQuestionTypeTranslation(array $question_data): string { - if (!($questionData['plugin'] ?? false)) { - return $this->lng->txt($questionData['type_tag']); + if (!($question_data['plugin'] ?? false)) { + return $this->lng->txt($question_data['type_tag']); } - global $DIC; - foreach ($DIC['component.factory']->getActivePluginsInSlot('qst') as $plugin) { - if ($plugin->getQuestionType() === $questionData['type_tag']) { + foreach ($this->component_factory->getActivePluginsInSlot('qst') as $plugin) { + if ($plugin->getQuestionType() === $question_data['type_tag']) { return $plugin->getQuestionTypeTranslation(); } } - return $this->lng->txt($questionData['type_tag']); + return $this->lng->txt($question_data['type_tag']); } public function getDataArrayForQuestionId(int $questionId) From f44d90ed05a6944a166ea351ae9422528c992f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= Date: Tue, 16 Jun 2026 13:01:13 +0200 Subject: [PATCH 3/3] [FIX] TestQuestionPool: Avoid extra type lookup in question GUI --- .../TestQuestionPool/classes/class.assQuestionGUI.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php index 0959fdc71152..259bb3bc3c0a 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php @@ -109,6 +109,7 @@ abstract class assQuestionGUI private ilDBInterface $db; protected ilLogger $logger; private ilComponentRepository $component_repository; + private ilComponentFactory $component_factory; protected GeneralQuestionPropertiesRepository $questionrepository; protected GUIService $notes_gui; protected ilCtrl $ctrl; @@ -177,6 +178,7 @@ public function __construct() $this->db = $DIC->database(); $this->logger = $DIC['ilLog']; $this->component_repository = $DIC['component.repository']; + $this->component_factory = $DIC['component.factory']; $this->refinery = $DIC['refinery']; $local_dic = QuestionPoolDIC::dic(); @@ -1068,10 +1070,10 @@ public function outQuestionType(): string 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; + foreach ($this->component_factory->getActivePluginsInSlot('qst') as $plugin) { + if ($plugin->getQuestionType() === $this->object->getQuestionType()) { + return $plugin->getQuestionTypeTranslation(); + } } return $this->lng->txt($this->object->getQuestionType());