Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83151

Quiz slots remained after questions were deleted as unused

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.14
    • Questions, Quiz
    • 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:

      1. Set up a fresh Moodle 3.9 site
      2. Same way as described in MDL-66273 hack 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);
        

      3. Enable asynchronous backups:

        php admin/cli/cfg.php --name='enableasyncbackup' --set=1
        

      4. Restore backup from MDL-66273 (backup-moodle2-course-3-test_course_for_mdl-66273-20220829-0446-nu-nf.mbz)
      5. In the first terminal, run the command to complete course restore:

        php admin/cli/adhoc_task.php --execute
        

      6. 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'
        

      7. Once restore is completed access the quiz and confirm that all 3 questions are marked as This question no longer seems to exist
      8. Confirm, that Quiz preview and Quiz question pages can be accessed
      9. Checkout to Moodle 4.1 codebase and run Moodle 3.9-4.1 upgrade
      10. 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)

       

            Unassigned Unassigned
            mikhailgolenkov Misha Golenkov
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

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