[ILIAS 10] [FIX] TestQuestionPool: Translate plugin question types#11642
[ILIAS 10] [FIX] TestQuestionPool: Translate plugin question types#11642Saaweel wants to merge 2 commits into
Conversation
kergomard
left a comment
There was a problem hiding this comment.
Hi @Saaweel
Thank you very much for the PR. I would kindly ask you to implement the following changes:
- Please do not introduce any variable in lowerCamelCase. All variables MUST be in snake_case.
- Please do not introduce any usages of the
$DICin classes that fully rely on dependency injection and never introduce a usage of the$DICin the middle of the class (if there absolutely needs to be a usage of the$DICit must be in theconstructor). In this case it should be injected betweenilComponentsRepositoryand?ilNotesService.
Thanks again and best,
@kergomard
|
Hi @kergomard, thanks for the feedback!
Regarding the injection as a constructor parameter: ilAssQuestionList is instantiated in numerous files across several components, and adding a required parameter would require changes in all of them. Since I am not the maintainer of those components, I preferred to keep the impact minimal and resolve the dependency in the constructor instead. Regards, |
|
Hello @Saaweel , first of all, thank you for analyzing the issue and implementing the fix! Could we reuse the same implementation that Something like this: private function getQuestionTypeTranslation(array $question_data): string
{
$local_dic = \ILIAS\TestQuestionPool\QuestionPoolDIC::dic();
$this->questionrepository = $local_dic['question.general_properties.repository'];
$question_properties = $this->questionrepository->getForQuestionId($question_data['obj_fi']);
$type_name = $question_properties?->getTypeName($this->lng);
if ($type_name !== null && $type_name !== '') {
return $type_name;
}
return $this->lng->txt($question_data['type_tag']);
}Of course without the Best regards |
Fix: Plugin question type is not translated in question pool
Mantis: #0047758
Problem
The question list in a question pool was not translating the type name of plugin questions. The
ilAssQuestionList::loadfunction was calling$this->lng->txt($row['question_type'])directly, bypassing the plugin's own translation mechanism. The same issue existed inassQuestionGUI::outQuestionType(), used byilTestCorrectionsGUI::populatePageTitleAndDescription.Solution
Added a
getQuestionTypeTranslation()helper method in bothilAssQuestionListandassQuestionGUIthat checks whether the question belongs to a plugin and, if so, delegates to$plugin->getQuestionTypeTranslation(). Otherwise it falls back to the standard language translation.Files changed
components/ILIAS/TestQuestionPool/classes/class.ilAssQuestionList.phpcomponents/ILIAS/TestQuestionPool/classes/class.assQuestionGUI.phpHow to test
ilTestCorrectionsGUI).