-
Improvement
-
Resolution: Won't Do
-
Minor
-
None
-
2.9
This patch switches Moodle's issuing of badges from being cron based to event based where possible and implements batching via an adhoc task when mass (re)checks of criteria are required. This avoids unnecessary and inefficient checking and rechecking of criteria that haven't yet been fulfilled when nothing has changed since the last cron run. A new admin setting controls the size of batches (default is 500). It should be noted that the batchsize is the number of criteria that are rechecked, not the number of badges that will be checked/issued. This means more complex badges won't still cause problems.
New functions in lib/classes/task/manager allow us to update an existing adhoc task so that if a badge that is already undergoing a batch review has something changed that would start another review, we simply reset the current review to the beginning.
The patch has grown a lot since it was first developed, due to feedback from Simey and Yulia. Despite its size, it has still been made as simple as possible. It checks the criteria for all unissued badges for a user when an event occurs that could result in criteria being fulfilled. Further optimisations could potentially provide the ability to just check the criteria (if any) related to the event.
The patch maintains the previous behaviour of not issuing badges prior to a course start date. To achieve this, it schedules a badge for review after the course start date where appropriate, skipping all checking of other criteria until that time.
Finally, additional tests are of course added to confirm the correct operation of the new code.
- has a non-specific relationship to
-
MDL-39864 Make badges criteria a sub-plugin to allow easier sharing of new types
-
- Reopened
-