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

Full course grade recalculation can have huge impact on opening/closing quizzes

    XMLWordPrintable

Details

    • MOODLE_28_STABLE, MOODLE_29_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-51360-403-2
    • MDL-51360-404-2
    • MDL-51360-main-2
    • Hide
      1. Create a course with a quiz and students
      2. As a student attempt a quiz (create several attempts) and get some score
      3. Navigate to a quiz page
      4. Ensure you see your see your best grade i.e. 'Highest grade: x / 10.00.' where x is the best grade across all attempts
      5. As a teacher go to a grader report and override the grade with some value (lets call it y)
      6. As a student refresh the quiz page
      7. Ensure you see 'Highest grade: y / 10.00.' where y is an overridden grade and a text 'Your final grade from this activity was manually adjusted.'{}
      8. Mark grade item needsupdate = 1 in database
      9. Refresh the page
      10. Ensure you see 'Highest grade: 0 / 10.00.'
      Show
      Create a course with a quiz and students As a student attempt a quiz (create several attempts) and get some score Navigate to a quiz page Ensure you see your see your best grade i.e. 'Highest grade: x / 10.00.' where x is the best grade across all attempts As a teacher go to a grader report and override the grade with some value (lets call it y) As a student refresh the quiz page Ensure you see 'Highest grade: y / 10.00.' where y is an overridden grade and a text 'Your final grade from this activity was manually adjusted.' { } Mark grade item needsupdate = 1 in database Refresh the page Ensure you see 'Highest grade: 0 / 10.00.'
    • 5
    • Team Alpha - Planning I2-2024

    Description

      There seems to be unnecessary grade recalculation of the whole course happening on view quiz page. And we only need the finalgrade of 1 student to notify him that grade is overridden. Depending on various scenarios this might have a huge performance impact (for example when there is an error in calculation formula for some other grade item in gradebook). We only need to pull those grades required.

       

      Old description (for history):

      If there is a (presumably unknown) error in a gradebook formula, e.g. it references a deleted activity item, there can be a massive impact on the performance of quizzes (at least their opening and closing) in the same course, with no indication of the cause of the problem. I have had this occur twice. On one occasion two affected quizzes were taking up to a minute to open. On another occasion there was a delay of just a few seconds but this had a major impact at the end of an exam when 200 quizzes were auto-closed and the system essentially crashed, with a large number of database errors.

      It appears that when the quiz is opened, a call is made on the gradebook to get a gradebook summary (perhaps to get the number of students who have attempted the quiz?). If the gradebook detects errors in the grades, a forced regarding takes place, which is what takes the time. Also, during this regrading, there is associated database locking, leading to database deadlock and lock timeout errors in the error log under load. Since the forced regrading is unable to resolve the underlying problem, the regrading re-occurs on every opening of the quiz.

      Although it might seem strange to be operating a course with a gradebook formula error, it occurs very easily, particularly when importing courses from a previous year and deleting some of the unwanted activities without being aware there are formulae referencing them.

      Steps to reproduce

      1. Pick a course with plenty of quizzes and at least a couple of hundred students, with grades recorded for the quizzes.
      2. Create a new quiz
      3. Open the gradebook and edit the calculation formula for the total of all quizzes to explicitly reference the newly created quiz (and the others) by giving all quizzes specific ids.
      4. Delete the new quiz. This breaks the quiz-total formula, and if you were to go back to the gradebook you'd find that the deleted grade item appears as something like ##gi<someid>##.
      5. Open any quiz and observe the delay.

      Other observations

      One of the disturbing aspects of this issue is that there is no evidence of the problem in the error logs, even with full logging on, until database errors occur, at which point valuable data may have been lost. I would suggest that when the gradebook module detects formula errors it should log them at a debug level, so a system administrator can be made aware of the underlying problem.

      With a delay of up to a minute occurring in one case, I'm guessing that the gradebook is attempting to regrade all students in the class. If so, is this an appropriate behaviour, once a formula error has been detected? Are they not all doomed to fail too? It seems particularly inappropriate to attempt to regrade the entire class when just a single student is trying to open a quiz.

      In the affected versions below, I have picked 2.8.6 for the second version, although I'm actually running 2.8.1 (not listed). I have checked the problem persists on 2.9.1, however, so I assume it's in 2.8.6 too. [Perhaps I should have picked "2.8 regressions" but I'm unfamiliar with that particular use of the term "regressions"].

      Attachments

        Issue Links

          Activity

            People

              ilyatregubov Ilya Tregubov
              trampgeek Richard Lobb
              Shamim Rezaie Shamim Rezaie
              Mihail Geshoski Mihail Geshoski
              Ron Carl Alfon Yu Ron Carl Alfon Yu
              Votes:
              11 Vote for this issue
              Watchers:
              27 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day, 5 hours, 11 minutes
                  1w 1d 5h 11m

                  Clockify

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