[ILIAS 10] [FIX] TestQuestionPool: Translate plugin question types#11642
[ILIAS 10] [FIX] TestQuestionPool: Translate plugin question types#11642Saaweel wants to merge 3 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 |
|
Hi @matheuszych, thank you for the suggestion! I aligned I also removed the One important detail: I used Regards, |
|
Hi @Saaweel and @matheuszych Sorry, the last change is not correct. I had looked into this, but this does make things worse: As far as I can see, this change would cost us one round trip to the database per question. This is f***** lot of round trips for something we already have in our hands. If we want do do this, we would need to move things around quite a bit, but this I would only do for trunk. If I didn't miss anything: Please revert the last change. Best, |
8cbd7fc to
e51beb8
Compare
|
Hi @kergomard, Right, I've removed that commit from the PR Best regards, |
kergomard
left a comment
There was a problem hiding this comment.
Hi @Saaweel
Sorry, I didn't think far enough this morning, when answering quickly: The other usage of $this->questionrepository->getForQuestionId($this->object->getId()) in assQuestionsGUI is also wrong. We do already have the information about the question type for non plugin questions, why would we call the database to retrieve it? ...but as far as I can see the solution you implemented for ilAssQuestionList should work for assQuestion, too.
Sorry again for missing this before.
Best,
@kergomard
|
Hi @kergomard, thanks for pointing this out. I adjusted Instead, it now uses the same approach as Best, |
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).