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

Investigate and fix invalid question_multianswer sequence

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_31_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • MOODLE_311_STABLE
    • MDL-54724-311
    • MDL-54724-master
    • Hide

      Without the patch applied:

      1. Create two course in the default category, "Course 1" and "Course 2"
      2. Add a quiz to each course (don't add any questions)
      3. Go to the question bank of Course 1 and create a cloze question in the "Default for Course 1" category with the following content:

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

      4. Add the question to the quiz in Course 1
      5. Go to the question bank for Course 1 and move the question to "Default for Category 1"
      6. Add the question to the quiz in Course 2
      7. Go to the question bank in Course 2 and move the question to "Default for Course 2"
      8. Delete Course 2 - doing this will remove questions from the mdl_question table, but leave them referenced in sequence column of the mdl_question_multianswer table)
      9. Create a backup of Course 1

      With the patch applied (on a vanilla install):

      1. Restore the backup from step 9 above
      2. Verify there are no errors and the course is restored
      3. Browse to the quiz in the restored course, preview it and verify a notification explaining that the question is corrupted displays, and that the text "This subquestion is missing from your system and cannot be displayed." is shown in place of the subquestion
      4. Verify you are able to edit the quiz without any errors

      With the patch applied (on a vanilla install):

      1. Repeat the steps to make the backup from before
      2. Go to Course 1 and verify the quiz is still working
      3. Restore the new backup on a vanilla moodle without the patch applied, and verify it restores and the question in the quiz works (preview and edit)
      4. Restore the new backup on a vanilla moodle with the patch applied and verify it restores and the question in the quiz works (preview and edit)
      Show
      Without the patch applied: Create two course in the default category, "Course 1" and "Course 2" Add a quiz to each course (don't add any questions) Go to the question bank of Course 1 and create a cloze question in the "Default for Course 1" category with the following content: {1:SHORTANSWER:=Berlin} is the capital of Germany. {1:SHORTANSWER:=Canberra} is the capital of Australia. Add the question to the quiz in Course 1 Go to the question bank for Course 1 and move the question to "Default for Category 1" Add the question to the quiz in Course 2 Go to the question bank in Course 2 and move the question to "Default for Course 2" Delete Course 2 - doing this will remove questions from the mdl_question table, but leave them referenced in sequence column of the mdl_question_multianswer table) Create a backup of Course 1 With the patch applied (on a vanilla install): Restore the backup from step 9 above Verify there are no errors and the course is restored Browse to the quiz in the restored course, preview it and verify a notification explaining that the question is corrupted displays, and that the text "This subquestion is missing from your system and cannot be displayed." is shown in place of the subquestion Verify you are able to edit the quiz without any errors With the patch applied (on a vanilla install): Repeat the steps to make the backup from before Go to Course 1 and verify the quiz is still working Restore the new backup on a vanilla moodle without the patch applied, and verify it restores and the question in the quiz works (preview and edit) Restore the new backup on a vanilla moodle with the patch applied and verify it restores and the question in the quiz works (preview and edit)

    Description

      There has been situations where restore or upgrade were compromised because of invalid values in the sequence column of multianswer (Cloze) questions. In this issue we should investigate and fix the root cause. It appears that sequences could contain empty values, e.g: ,,.

      One of the causes could be that mappings to new question IDs were not found during restore, thus creating $sequence = implode(',', array(1, false, 3, ...)). That is based on my observations from MDL-35987.

      The following SQL statement may help identify invalid sequences:

      SELECT *
        FROM mdl_question_multianswer
       WHERE sequence IS NULL
          OR sequence LIKE ''
          OR sequence LIKE '%,,%';
      

      Attachments

        1. broken-backup.mbz
          20 kB
        2. data-model.png
          data-model.png
          1.12 MB
        3. faulty_multianswer_questions_moodle.xlsx
          20 kB
        4. image-2018-09-29-18-58-38-529.png
          image-2018-09-29-18-58-38-529.png
          185 kB
        5. image-2018-10-01-09-52-38-202.png
          image-2018-10-01-09-52-38-202.png
          220 kB
        6. MDL-54724_master_1.png
          MDL-54724_master_1.png
          54 kB
        7. MDL-54724_master_2.png
          MDL-54724_master_2.png
          85 kB
        8. MDL-54724_master_3.png
          MDL-54724_master_3.png
          47 kB
        9. MDL-54724_master_4.png
          MDL-54724_master_4.png
          69 kB
        10. MDL-54724_master_5.png
          MDL-54724_master_5.png
          68 kB
        11. MDL-54724_master_6.png
          MDL-54724_master_6.png
          54 kB
        12. MDL-54724_master_7.png
          MDL-54724_master_7.png
          68 kB
        13. Screenshot-2018-09-29-18-28-57.jpg
          Screenshot-2018-09-29-18-28-57.jpg
          205 kB

        Issue Links

          Activity

            People

              cameron1729 cameron1729
              fred Frédéric Massart
              Tim Hunt Tim Hunt
              Victor Déniz Falcón Victor Déniz Falcón
              Angelia Dela Cruz Angelia Dela Cruz
              Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
              Votes:
              63 Vote for this issue
              Watchers:
              55 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                14/Mar/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 5 minutes
                  4h 5m