Fixing question bank copying [MDL-77625]

Fixing question bank copying [MDL-77625]

by Julien Rädler -
Number of replies: 2

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.

flow_1.drawio%20%284%29.png

Step 2:

The quiz including question bank is copied from the source course into the destination course.

flow_2.drawio.png

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.

flow_3.drawio.png

Step 4:

The quiz, including the question bank, is copied from the source course into the destination course again.

flow_4.drawio.png

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.)

wrong_flow_5.drawio%20%281%29.png

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.

right_flow_5.drawio.png

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.)

FlowChart.drawio.png

Greetings Julien

In reply to Julien Rädler

Re: Fixing question bank copying [MDL-77625]

by Tim Hunt -
Many people want this bug fixed. The way you say it should work is they way it should work.

But, all I will say is "good luck". (Your assumption just above the last diagram is wrong.)
In reply to Tim Hunt

Re: Fixing question bank copying [MDL-77625]

by Julien Rädler -
Since there is no tracking of IDs, the easiest solution seems to be to compare the names of the questions belonging to a question bank with the same name on a per-question basis. This would make it work like the file manager on a desktop and follow the same logic as depicted above.
Can you think of any foreseeable challenges that should be kept in mind with this approach, or are you aware of anyone already working on a solution for this problem?