Hello everyone
I would like to pitch a plugin that solves the "quiz question references a question in another course's question bank" bug. The bug is also reported in the moodle tracker [MDL-77625].
Problem description
First import ⇾ Questions are copied from source to destination course.
Second import ⇾ Questions are not copied but referenced to questions in the source course.
Step by Step
Step 1:
Starting point is an empty course (Destination Course) and a course (Source Course) containing a question bank on course level and a quiz using the questions from the question bank.
Step 2:
The quiz including question bank is copied from the source course into the destination course.
Step 3:
The destination course now contains a unique question bank (has its own ID) that's a copy of the source course question bank. The question bank in the destination course contains unique (with their own ID) questions that are copies of the questions in the source course.
Step 4:
The quiz, including the question bank, is copied from the source course into the destination course again.
Step 5 (How it is now):
The quiz, including its questions, is copied from the source course into the destination course, but all the questions in the copied quiz in the destination course reference the question bank in the source course. (This behavior is most likely caused because Moodle is checking if the question bank already exists in the destination course. If that is the case, it doesn't copy it again and doesn't check for changes. It just copies the quiz, but the questions in this quiz still reference the questions in the question bank of the source course.)
Step 5 (How it should be):
The desired result would be, that the questions in the second quiz copy in the destination course reference the question bank in the destination course.
Modification of the saving logic
Here is a flow chart showcasing how the copying could work, assuming Moodle keeps track of if a question is a copy of another question. (If there is no tracking of questions and their copies, a simple name check analog to moving files on a computer could be done.)
Greetings Julien