During the upgrade to 5.x, question categories are moved to new
mod_qbank module contexts, and any set references using those categories
are updated using `move_question_set_references()`. However, this
function wasn't updating the `cat` arribute of the set reference's
filter condition, leaving it pointing at the original context ID.
This change update `move_question_set_references()` so that when a set
reference is moved (during the 5.x upgrade, or otherwise) the `cat`
parameter will be updated correctly.
For sites that have already gone through the 5.x upgrade, this fix also
adds a CLI script to find and fix incorrect question_set_reference
records. I considered adding this as an upgrade step, but it potentially
has a lot of records to check, and it's redundant if the site is being
upgraded to 5.x with this fix already in place.
The core backup code was taking sole responsibility for conversion and
mapping of IDs in set reference filter conditions during restores.
However, it was only actually processing category conditions, not tags
or any of the more recently added conditions.
This adds a new `restore_filtercondition` method to the
`core_question\local\bank\condition` class which can be overridden by
each condition to convert IDs and add mappings during the restore
process.
It also adds a new `maptags` option to
`convert_legacy_set_reference_filter_condition`, so that if we are
doing the conversion during a restore, we don't also create or map
the tags as they are converted. We record ID mappings of the tags
as the are restored, then these can be used by the
`qbank_tagquestions` plugins later to map the converted condition.
- Adds the "cat" field to the converted legacy filter, which was
missing.
- Does the conversion on the editrandom.php page as this was
throwing a warning.