diff --git a/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.php index 276d500882b6..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(); @@ -1063,6 +1065,17 @@ public function outQuestionType(): string } } + return $this->getQuestionTypeTranslation(); + } + + private function getQuestionTypeTranslation(): string + { + foreach ($this->component_factory->getActivePluginsInSlot('qst') as $plugin) { + if ($plugin->getQuestionType() === $this->object->getQuestionType()) { + return $plugin->getQuestionTypeTranslation(); + } + } + 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..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 @@ -603,7 +607,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 +703,21 @@ private function isActiveQuestionType(array $questionData): bool ->isActive(); } + 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(); + } + } + + return $this->lng->txt($question_data['type_tag']); + } + public function getDataArrayForQuestionId(int $questionId) { return $this->questions[$questionId];