mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 14:15:11 +02:00
MDL-78082 core_grades: Fix locking issue with natural aggregation
Problem: When the aggregation method is set to "natural," grade items' weights and the maximum grade of the grade category's item get recalculated, causing the needsupdate flag to be set to true. As a result, the locking process was skipped, leading to unexpected behaviour. Solution: To address the issue, the set_locked method has been modified. Instead of skipping the locking process, the method now schedules the locking of grade items to occur slightly in the past, specifically one second in the past. This ensures that the grade item will be automatically locked after the recalculations are completed. Explanation: By making this adjustment, we ensure that the locking process is not skipped during natural aggregation, maintaining consistent behaviour and preventing any unintended consequences related to grade item locking.
This commit is contained in:
parent
a1cf8f143a
commit
fb3f018cf6
@ -68,7 +68,7 @@ define('GRADE_AGGREGATE_WEIGHTED_MEAN2', 11);
|
||||
define('GRADE_AGGREGATE_EXTRACREDIT_MEAN', 12);
|
||||
|
||||
/**
|
||||
* GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use Natural in the category for grade aggregation.
|
||||
* GRADE_AGGREGATE_SUM - Use Natural in the category for grade aggregation.
|
||||
*/
|
||||
define('GRADE_AGGREGATE_SUM', 13);
|
||||
|
||||
|
@ -649,12 +649,16 @@ class grade_item extends grade_object {
|
||||
*/
|
||||
public function set_locked($lockedstate, $cascade=false, $refresh=true) {
|
||||
if ($lockedstate) {
|
||||
/// setting lock
|
||||
if ($this->needsupdate) {
|
||||
return false; // can not lock grade without first having final grade
|
||||
// Setting lock.
|
||||
if (empty($this->id)) {
|
||||
return false;
|
||||
} else if ($this->needsupdate) {
|
||||
// Can not lock grade without first having final grade,
|
||||
// so we schedule it to be locked as soon as regrading is finished.
|
||||
$this->locktime = time() - 1;
|
||||
} else {
|
||||
$this->locked = time();
|
||||
}
|
||||
|
||||
$this->locked = time();
|
||||
$this->update();
|
||||
|
||||
if ($cascade) {
|
||||
|
@ -59,7 +59,7 @@ information provided here is intended especially for developers.
|
||||
the page displays a heading for the activity (usually a h2 heading containing the activity name).
|
||||
* New method moodleform::filter_shown_headers() is created to show some expanded headers only and hide the rest.
|
||||
* count_words() and count_letters() have a new optional parameter called $format to format the text before doing the counting.
|
||||
* New core_renderer::sr_text method to generate screen reader only inline texts without using html_writter.
|
||||
* New core_renderer::sr_text method to generate screen reader only inline texts without using html_writer.
|
||||
* New events \core\event\qbank_plugin_enabled and \core\event\qbank_plugin_disabled are triggered when a qbank plugin is enabled or
|
||||
disabled respectively, with the plugin's frankenstyle name. Any plugins that need to perform an action in response to a qbank
|
||||
plugin being enabled or disabled should observe these events.
|
||||
@ -158,6 +158,8 @@ being forced open in all behat tests.
|
||||
but a subset can be specified instead.
|
||||
* core/form-autocomplete now supports disabled options in the source select list. These will be displayed in the autocomplete
|
||||
options with the aria-disabled attribute, and will not be selectable.
|
||||
* The method grade_item::set_locked() now returns true if the grade item needs to be updated. The method schedules the locking of
|
||||
the grade item once the recalculations are completed. (This was fixed in 4.3, 4.2.2)
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user