-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.14
-
MOODLE_401_STABLE
Tried to look for an existing tracker for this issue but couldn't find any.
It seems to be related to MDL-66273 where we had `\qtype_random\task\remove_unused_questions` scheduled task removing questions during backup restore due to a race condition. In MDL-66273 we fixed the task but removed questions couldn't be restored. Also, it looks like while questions were removed by the task their slots remained. This issue has been carried over to 4.1 and now quizes that have orphaned slots cannot be previewed and cannot be edited . Please see screenshots attached below.
Quiz preview page:
Quiz questions page:
Steps to replicate:
- Set up a fresh Moodle 3.9 site
- Same way as described in
MDL-66273hack the codebase https://github.com/moodle/moodle/blob/376e57d267254d676a7cac488cb51183a5bd64d5/mod/quiz/backup/moodle2/restore_quiz_stepslib.php#L302 with the following two lines (this is to simulate the race condition):mtrace('Restoring question instance');
sleep(10);
- Enable asynchronous backups:
php admin/cli/cfg.php --name='enableasyncbackup' --set=1
- Restore backup from
MDL-66273(backup-moodle2-course-3-test_course_for_mdl-66273-20220829-0446-nu-nf.mbz) - In the first terminal, run the command to complete course restore:
php admin/cli/adhoc_task.php --execute
- Once Restoring question instance text is appeared in the CLI output, run the scheduled task in another terminal:
php admin/cli/scheduled_task.php --execute='\qtype_random\task\remove_unused_questions'
- Once restore is completed access the quiz and confirm that all 3 questions are marked as This question no longer seems to exist
- Confirm, that Quiz preview and Quiz question pages can be accessed
- Checkout to Moodle 4.1 codebase and run Moodle 3.9-4.1 upgrade
- Once 4.1 upgrade is completed access the quiz and confirm that Quiz preview and Quiz question pages can no longer be accessed (exceptions are thrown)
- has been marked as being related by
-
MDL-66273 Restoring quizzes with random questions while cleanup task runs causes issues
-
- Closed
-