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

Quiz cron not closing old attempts after quiz close date

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.3.2, 2.3.8
    • 2.3.4, 2.4
    • Quiz
    • MOODLE_23_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MDL-35717-quiz-attempt-checkstate
    • Hide

      Open mod/quiz/cronlib.php and find the chunk of code that looks like

                WHERE iquiza.state IN ('inprogress', 'overdue')
                  AND iquiza.timemodified >= :processfrom
                  AND iquiza.timemodified < :processto

      Delete the middle of those three lines, so that it looks like

                WHERE iquiza.state IN ('inprogress', 'overdue')
                  AND iquiza.timemodified < :processto

      If you have a small Moodle site, then you can probably do that without worrying.

      If the quiz_attempts table if you Moodle site has a lot of rows, then making this change may cause cron to run unacceptably slowly. (It would be useful to know how slow it is, if anyone tries it on a big site.)

      Show
      Open mod/quiz/cronlib.php and find the chunk of code that looks like WHERE iquiza.state IN ('inprogress', 'overdue') AND iquiza.timemodified >= :processfrom AND iquiza.timemodified < :processto Delete the middle of those three lines, so that it looks like WHERE iquiza.state IN ('inprogress', 'overdue') AND iquiza.timemodified < :processto If you have a small Moodle site, then you can probably do that without worrying. If the quiz_attempts table if you Moodle site has a lot of rows, then making this change may cause cron to run unacceptably slowly. (It would be useful to know how slow it is, if anyone tries it on a big site.)
    • Hide

      Really, we need to re-run QA tests MDLQA-4166 to MDLQA-4177, or at least the parts of them that involve cron.

      Testing instructions for the initial problem:
      1. Create a quiz with a close date enough in the future to run steps 2 and 3 first. Set the quiz to automatically submit attempts when time expires.
      2. Attempt the quiz as a student, but don't finish the attempt.
      3. Run the moodle cron.
      4. Verify that the student attempt hasn't been closed.
      5. Wait long enough that the quiz has been closed for at least quiz mingraceperiod (60 secs by default), and run the moodle cron again.
      6. Verify that the student attempt has closed. (Note: this check should be done as the instructor, since the student viewing his own attempt will close it on view.)

      (To replicate the problem in current moodle, note that the overdue attempt processor only runs a maximum of once an hour. This patch eliminates the need for that delay, as well as fixes the bug.)

      Show
      Really, we need to re-run QA tests MDLQA-4166 to MDLQA-4177, or at least the parts of them that involve cron. Testing instructions for the initial problem: 1. Create a quiz with a close date enough in the future to run steps 2 and 3 first. Set the quiz to automatically submit attempts when time expires. 2. Attempt the quiz as a student, but don't finish the attempt. 3. Run the moodle cron. 4. Verify that the student attempt hasn't been closed. 5. Wait long enough that the quiz has been closed for at least quiz mingraceperiod (60 secs by default), and run the moodle cron again. 6. Verify that the student attempt has closed. (Note: this check should be done as the instructor, since the student viewing his own attempt will close it on view.) (To replicate the problem in current moodle, note that the overdue attempt processor only runs a maximum of once an hour. This patch eliminates the need for that delay, as well as fixes the bug.)

    Description

      We see lots of quiz attempts staying in the "In progress" state after quizzes close.
      Attempts modified within one hour of the close date are closed (in a way depending on quiz settings), but previous attempts are left open.

      There is an SQL WHERE clause in get_list_of_overdue_attempts() (mod/quiz/cronlib.php) that selects only recent quiz attempts:

                WHERE iquiza.state IN ('inprogress', 'overdue')
                  AND iquiza.timemodified >= :processfrom
                  AND iquiza.timemodified < :processto

      I think the middle line is causing this. Removing that line should fix the problem, although it removes the incremental processing aspect to the code. On our new 2.3 site with 20k attempts, the full query with processfrom=0 finishes in milliseconds, so this might not be an issue.

      Attachments

        Issue Links

          Activity

            People

              mpetrowi Matt Petro
              mpetrowi Matt Petro
              Tim Hunt Tim Hunt
              Dan Poltawski Dan Poltawski
              David Monllaó David Monllaó
              Tim Hunt, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              9 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3/Dec/12