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

Regrading a quiz in progress causes student to lose data

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Setup

      1. As admin
      2. Ensure that "autosaveperiod" is set to "1 minutes" in the "Administration > Plugins > Activity modules > Quiz".
      3. Create a course with a editing-teacher and a student enrolled.
      4. Open 2 separated sessions (2 browsers or incognito), one as a editing-teacher and another as student.

      Test with the patch NOT applied (before patch)

      1. With the editing-teacher session/browser
        1. Create a new quiz in the course.
        2. Add a new question to this quiz (a simple true/false one is ok).
      2. With the student session/browser
        1. Start a new attempt of this quiz and answer the question (just click on true or false, don't finish the attempt.
        2. Wait until the answer was saved in background (autosave step created). You can do that by just waiting more than "1 minute" or, looking to the web server logs... until you see a "mod/quiz/autosave.ajax.php" request there (that will mean that the auto-save has happened).
      3. With the editing-teacher session/browser
        1. Go to quiz and click on "Attempts: 1". You should see an "in progress" attempt from the student user.
        2. Select it and click on " Regrade selected attempts". You should see "Successfully regraded (1/1)"
      4. With the student session/browser
        1. Finish the attempt.
        2. Verify that you get an error like "You have entered data outside the normal sequence. This can occur...."

      Test with the patch applied (after patch)

      1. Repeat all the steps in the previous section.
      2. Verify that, in the last step, instead of the error, you get the option to submit the attempt.
      Show
      Setup As admin Ensure that "autosaveperiod" is set to "1 minutes" in the "Administration > Plugins > Activity modules > Quiz". Create a course with a editing-teacher and a student enrolled. Open 2 separated sessions (2 browsers or incognito), one as a editing-teacher and another as student. Test with the patch NOT applied (before patch) With the editing-teacher session/browser Create a new quiz in the course. Add a new question to this quiz (a simple true/false one is ok). With the student session/browser Start a new attempt of this quiz and answer the question (just click on true or false, don't finish the attempt. Wait until the answer was saved in background (autosave step created). You can do that by just waiting more than "1 minute" or, looking to the web server logs... until you see a "mod/quiz/autosave.ajax.php" request there (that will mean that the auto-save has happened). With the editing-teacher session/browser Go to quiz and click on "Attempts: 1". You should see an "in progress" attempt from the student user. Select it and click on " Regrade selected attempts". You should see "Successfully regraded (1/1)" With the student session/browser Finish the attempt. Verify that you get an error like "You have entered data outside the normal sequence. This can occur...." Test with the patch applied (after patch) Repeat all the steps in the previous section. Verify that, in the last step, instead of the error, you get the option to submit the attempt.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull from Repository:
    • Pull 3.6 Branch:
    • Pull 3.7 Branch:
    • Pull Master Branch:
      MDL-58026-master

      Description

      Some more background is here: https://moodle.org/mod/forum/discuss.php?d=344367

      High level

      If a teacher uses the regrade feature on a quiz attempt that is currently in progress and has autosave data, the autosave step data is converted to a true step. When the student attempts to submit their quiz, they will get an out of sequence error ("You have entered data outside the normal sequence", question_out_of_sequence_exception), and all data will be lost from the point of the most recent autosave before the teacher hit regrade.

      Details

      When a user is attempting a quiz, they are assigned a sequence number in the form, which is the next not submitted sequence (starting at 1, and going up), that way, if they have the quiz open in two windows, they will both get sequence 1. When they hit submit in one (now saving sequence 1 to the DB), if they try to submit from the other, it won't overwrite the answers, because sequence 1 already exists. When they load the page again, then would get sequence 2, since that is the next not used sequence.

      Auto-save from a quiz window is saved under the sequence number, but negative (-1, -2, etc).

      If there is autosave data (let's say we are working under sequence 2, so autosave is stored as sequence -2), and the attempt is regraded by the teacher (like by hitting regrade all), all the auto-save steps are converted to positive sequence numbers (so -2 becomes 2).

      Now two things happen:

      • When the user attempts to submit the page, they will get an out of sequence error, and be moved back to the attempt, but all data since the time the teacher hit regrade all is gone (and if time was up, it will immediately resubmit, successfully). The error page is just regular text with a continue button, not styled as a warning/error, so many students don't even realize it's telling them a warning.
      • Auto-save silently stops working. Autosave on the page still calls autosave.ajax.php, and that page still returns "OK", which should mean it recorded fine, but in fact, the data isn't recorded in the DB at all. Basically autosave seems to silently ignore out of sequence errors and report OK.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mgauk Martin Gauk
              Reporter:
              emerrill Eric Merrill
              Peer reviewer:
              Tim Hunt
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              13 Vote for this issue
              Watchers:
              14 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Sep/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours
                  3h