-
Improvement
-
Resolution: Fixed
-
Minor
-
4.2.4, 4.3.4, 4.4.1, 5.0
-
MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_500_STABLE
-
MOODLE_500_STABLE
-
MDL-81714_main -
-
-
Since MDL-75878, We have been seeing teachers in very large courses (students x activities) having to wait a very long time for the regrading of final grades to take place before they can perform any other action in Moodle - this is usually triggered after creating an activity like a quiz - but cannot start editing the quiz until the course level recalculations have been completed, other users are unaffected and can keep navigating the course .
We should move the processing into an ad-hoc task and free the teachers to keep editing the course.
We have developed a patch for this which has made a significant performance impact:
Before:
- ~ 3.5 minutes for regrade to complete and then next page is instant.
After:
- by using "Save and display" - ~6.75s
- by using "Save and return to course" - ~19s
I'm guessing return to course is slower because it'll hit the coursemodinfo partial rebuild lock, but overall massive difference
Reproduction steps
You will need to have access to save and run CLI scripts in your Moodle installation.
1 In your Moodle, go to Site administration / Development / Make test course and create a medium (M) sized course with your preferred short name and full name.
2 In the test courses, users do not have grades, so we will create some. Save the file creategrades.php (attached to this issue) into the root directory of your Moodle installation.
3 Run it with php creategrades.php 1234 where 1234 is the course id of your medium test course. This script will create random grades for all users on all 100 assignments on the course, but you don't need to wait for it to do that (which will take several hours). Just wait until it says Assignment 1: done (which should be less than 5 minutes) then press Ctrl+C to exit the script.
- For some reason I don't understand, this is actually enough to fill in blank grades for all the assignments, so it has the full performance impact just like running it for all of them.
4 Back in your medium course, turn editing on and click Add an activity or resource and then choose Quiz.
5 Type in a name for the quiz, but make no other changes (don't save yet)
6 Click Save and display
- You should be taken to another page with heading Recalculating grades and a progress bar. (Depending on the configuration of your web server, the page might not actually appear before the progress bar finishes.)
- This process will take about 30s in this scenario. As described above, it can take several minutes on large complex courses.
7 Click Continue
- You should get to the quiz activity.
- has a non-specific relationship to
-
MDL-49324 Recalculating final grades is sometimes necessarily slow
-
- Closed
-
- is a regression caused by
-
MDL-75878 Course: Adding graded activity does not show progress bar when slow due to lots of grades
-
- Closed
-
- is blocked by
-
MDL-70854 New api to allow adhoc tasks to communicate a progress bar / status back to the calling page
-
- Closed
-
- is duplicated by
-
MDL-80531 Progress bar displayed when editing large courses
-
- Closed
-
- will help resolve
-
MDL-84467 Adding a gradable activity takes 15-30 min in courses with tens of thousands of participants
-
- Closed
-
- links to