Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85369

Conversion of legacy random question filter conditions for the question area is breaking quizzes

XMLWordPrintable

      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:

      1. Create a Moodle 4.1 site.
      2. Create a new tag collection with the name "Questions" (or any non-default collection).
      3. Assign the question tag area to this new created collection.
      4. Create a course and add a quiz.
      5. Go to the question bank, create a question and associate a new tag.
      6. Go to the quiz and add a random question and configure it to filter questions by that tag.
      7. Upgrade the site to Moodle 4.3+.
      8. 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.

       

        1. (1) 1 Passed -- (Main)MDL-85369.png
          73 kB
          Kim Jared Lucas
        2. (1) 2 Passed -- (Main)MDL-85369.png
          107 kB
          Kim Jared Lucas

            Unassigned Unassigned
            guillermogomez@catalyst-au.net Guillermo Gomez Arias
            Mark Johnson Mark Johnson
            Tim Hunt Tim Hunt
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 31 minutes
                31m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.