-
Bug
-
Resolution: Fixed
-
Minor
-
4.3.12, 4.4.9, 4.5.5, 5.0.1, 5.1
Currently, the function convert_legacy_set_reference_filter_condition checks whether a filter condition is legacy, and if the tag doesn't exist in collection 1, it creates the tag in collection 1 by default.
However, if the "question" area was moved to another collection, it still creates the tag in collection 1, resulting in a duplicate tag and breaking the quiz, because there are no questions associated with that new tag in the intended collection.
The function should instead check the collection where the "question" tag area exists before creating the tag.
To reproduce:
- Create a Moodle 4.1 site.
- Create a new tag collection with the name "Questions" (or any non-default collection).
- Assign the question tag area to this new created collection.
- Create a course and add a quiz.
- Go to the question bank, create a question and associate a new tag.
- Go to the quiz and add a random question and configure it to filter questions by that tag.
- Upgrade the site to Moodle 4.3+.
- Have a user access the quiz (or attempt to preview it).
Expected result:
The quiz loads normally or shows an informative message if there are no matching questions.
Actual result:
The quiz throws an error:
There are not enough questions in category *** to create the question Random question (***).
Root cause:
During runtime, convert_legacy_set_reference_filter_condition() tries to convert old tag-based filters. It uses core_tag_tag::create_if_missing() with a hardcoded tag collection ID (1), which leads to the creation of duplicate tags in the wrong collection. Since no questions are tagged in collection 1, the random question filter yields zero results and the quiz fails to load.
- is a regression caused by
-
MDL-72321 Better searching/filtering in the question bank, so more flexible randomisation in quizzes
-
- Closed
-
- is duplicated by
-
MDL-84942 Random questions with pre 4.3 filtercondition syntax lead to wrongly duplicated question tags in the default tag collection and to not usable random questions
-
- Closed
-