Uploaded image for project: 'Moodle'
  1. Moodle
  2. 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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.4.7, 4.5.3
    • Questions, Tags
    • None

      The function convert_legacy_set_reference_filter_condition() (see https://github.com/moodle/moodle/blob/c64e967ce61880554dc3e4fb7d2f2328ee01b8bc/question/classes/question_reference_manager.php#L103-L115) is used for e.g.

      • generating links when looking at question lists containing random questions
      • populating the filter conditions form for random questions

      Every time this function is called, there is a chance that the entry of the question_set_references table contains a filtercondition with the old syntax, e.g.

      {"questioncategoryid":"SOME_QUESTION_CATEGORY_ID","includingsubcategories":"TRUE/FALSE","tags":["UNKNOWN_STRING, NAME_OF_SOME_QUESTION_TAG"]}

      I haven't deciphered what UNKNOWN_STRING was originally...

      The function then extracts NAME_OF_SOME_QUESTION_TAG and ensures that the tag exists by creating it in the default tag collection (or rather the tag collection with id 1). This leads to numerous unwanted and unnecessary tags in the tag collection with id 1.

      Instead it should ensure the tag is present in the tag collection for the tag area with component 'core_question' and itemtype 'question'.

      The function is also used in the filter condition form. This leads to the form not containing any entry for the tag filter, because

      • it translates the old filtercondition to the new format, possibly creating an id 1 collection tag
      • the new format then contains the id of a tag that isn't in the question tag collection and thus will not be shown

      If you then search for the old tag using NAME_OF_SOME_QUESTION_TAG, the user of course finds the question tag and can save the new filtercondition value.

      After this, everything is fine for this random question. But not for the hundreds of other random questions.

      I'm unsure if this bug affects more than random questions using the old filtercondition syntax. Meaning I'm not sure if the question_set_references table is used in any other way.

            poggenpohlda Daniel Poggenpohl
            poggenpohlda Daniel Poggenpohl
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 45 minutes
                1h 45m

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