MDL-52578 core_course: Activity weight set to 0 on creation
authorSteve Bader <smbader@ncsu.edu>
Tue, 11 Jun 2019 15:12:35 +0000 (11:12 -0400)
committerJun Pataleta <jun@moodle.com>
Tue, 19 May 2020 17:28:59 +0000 (01:28 +0800)
course/modlib.php

index 979e6cb..16ee3f5 100644 (file)
@@ -277,6 +277,12 @@ function edit_module_post_actions($moduleinfo, $course) {
             if ($update) {
                 $item->update();
             }
+            $gradecategory = $grade_item->get_parent_category();
+            if (!empty($moduleinfo->add)) {
+                if ($grade_item->set_aggregation_fields_for_aggregation(0, $gradecategory->aggregation)) {
+                    $grade_item->update();
+                }
+            }
         }
     }
 
@@ -333,6 +339,12 @@ function edit_module_post_actions($moduleinfo, $course) {
                 } else if (isset($moduleinfo->gradecat)) {
                     $outcomeitem->set_parent($moduleinfo->gradecat);
                 }
+                $gradecategory = $outcome_item->get_parent_category();
+                if ($outcomeexists == false) {
+                    if ($outcome_item->set_aggregation_fields_for_aggregation(0, $gradecategory->aggregation)) {
+                        $outcome_item->update();
+                    }
+                }
             }
         }
     }