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

Investigate duplicate sequences in question_multianswer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.0.1
    • Quiz
    • MOODLE_400_STABLE

      This is similar to MDL-54724 in that it leads to corrupted backups; but via a different (yet unknown) cause. MDL-54724 fixed the problem where corrupted backups cannot be restored, and it also fixed one of the situations that can lead to them being created. This issue is about a second kind of situation that leads to corrupted backups.

      MDL-54724 has comments making mention of the duplicated sequence situation; but it was not addressed in the patch there (as no one found reproduction steps). This issue is about investigating how those duplicated sequence records come to be.

      To see why this is a problem, we can reproduce it manually (NB these are not reproduction steps in the sense that they help us find and fix the issue, they are only to illustrate why this DB state is a problem):

      1. Create two courses
      2. Add a quiz in each course
      3. Add a cloze question to each quiz using:

        {1:SHORTANSWER:=Berlin} is the capital of Germany.
        {1:SHORTANSWER:=Canberra} is the capital of Australia.
        

        NB It must be a separate question instance unique to each quiz, do not put the question in the content bank and share it between the quizzes or something like that - also keep track of which course the question was added to first (important for later)

      4. The question_multianswer table now looks like this:
        id question sequence
        1 1 2,3
        2 4 5,6
      5. Edit it to look like this:
        id question sequence
        1 1 2,3
        2 4 2,3
      6. Make a backup of the second course (i.e., not the course that the question was first added to)
      7. View the quiz in the second course, note that it works (this is possibly also a bug, because it is referencing subquestions that it shouldn't have access to)
      8. Restore the backup
        • If you are using postgres it will fail
        • If you are using MySQL you'll probably have a {question_multianswer}record with a sequence like {,}

          (a single comma)

      Note that if the duplicate sequences are for two questions in the same course, everything still works. The problem happens when there is a sequence for a question in one course, which is referencing question ids from another course.

      This situation definitely arises in the wild; we need to figure out how to reproduce it via some user action.

            Unassigned Unassigned
            cameron1729 cameron1729
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

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