Merge branch 'MDL-52578-master' of git://github.com/junpataleta/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2020-05-21 00:51:10 +02:00
commit a5a8ca5e62

View file

@ -277,6 +277,13 @@ function edit_module_post_actions($moduleinfo, $course) {
if ($update) { if ($update) {
$item->update(); $item->update();
} }
if (!empty($moduleinfo->add)) {
$gradecategory = $item->get_parent_category();
if ($item->set_aggregation_fields_for_aggregation(0, $gradecategory->aggregation)) {
$item->update();
}
}
} }
} }
@ -298,8 +305,8 @@ function edit_module_post_actions($moduleinfo, $course) {
if (property_exists($moduleinfo, $elname) and $moduleinfo->$elname) { if (property_exists($moduleinfo, $elname) and $moduleinfo->$elname) {
// Check if this is a new outcome grade item. // Check if this is a new outcome grade item.
$outcomeexists = false;
if ($items) { if ($items) {
$outcomeexists = false;
foreach($items as $item) { foreach($items as $item) {
if ($item->outcomeid == $outcome->id) { if ($item->outcomeid == $outcome->id) {
$outcomeexists = true; $outcomeexists = true;
@ -333,6 +340,13 @@ function edit_module_post_actions($moduleinfo, $course) {
} else if (isset($moduleinfo->gradecat)) { } else if (isset($moduleinfo->gradecat)) {
$outcomeitem->set_parent($moduleinfo->gradecat); $outcomeitem->set_parent($moduleinfo->gradecat);
} }
if (!$outcomeexists) {
$gradecategory = $outcomeitem->get_parent_category();
if ($outcomeitem->set_aggregation_fields_for_aggregation(0, $gradecategory->aggregation)) {
$outcomeitem->update();
}
}
} }
} }
} }