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 8cbd7fc887d8d5371244d0f0b1d868b9771a3b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= Date: Thu, 11 Jun 2026 13:12:29 +0200 Subject: [PATCH 3/3] [FIX] TestQuestionPool: Align question list type translation --- .../classes/class.ilAssQuestionList.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php index d7046c9e6df0..6de407e8b9cc 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php +++ b/components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.php @@ -20,6 +20,8 @@ use ILIAS\Data\Range; use ILIAS\Notes\Service as NotesService; use ILIAS\Refinery\Factory as Refinery; +use ILIAS\TestQuestionPool\QuestionPoolDIC; +use ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository; /** * Handles a list of questions @@ -74,7 +76,7 @@ class ilAssQuestionList implements ilTaxAssignedItemInfo private ?Order $order = null; private ?Range $range = null; - private ilComponentFactory $component_factory; + private GeneralQuestionPropertiesRepository $question_repository; public function __construct( private ilDBInterface $db, @@ -83,8 +85,8 @@ public function __construct( private ilComponentRepository $component_repository, private ?NotesService $notes_service = null ) { - global $DIC; - $this->component_factory = $DIC['component.factory']; + $local_dic = QuestionPoolDIC::dic(); + $this->question_repository = $local_dic['question.general_properties.repository']; } public function setOrder(?Order $order = null): void @@ -705,14 +707,10 @@ private function isActiveQuestionType(array $questionData): bool private function getQuestionTypeTranslation(array $question_data): string { - if (!($question_data['plugin'] ?? false)) { - return $this->lng->txt($question_data['type_tag']); - } - - foreach ($this->component_factory->getActivePluginsInSlot('qst') as $plugin) { - if ($plugin->getQuestionType() === $question_data['type_tag']) { - return $plugin->getQuestionTypeTranslation(); - } + $question_properties = $this->question_repository->getForQuestionId($question_data['question_id']); + $type_name = $question_properties?->getTypeName($this->lng); + if ($type_name !== null && $type_name !== '') { + return $type_name; } return $this->lng->txt($question_data['type_tag']);