Merge branch 'MDL-45029-master' of git://github.com/lameze/moodle
authorDamyon Wiese <damyon@moodle.com>
Wed, 20 Aug 2014 02:21:20 +0000 (10:21 +0800)
committerDamyon Wiese <damyon@moodle.com>
Wed, 20 Aug 2014 02:21:20 +0000 (10:21 +0800)
course/modlib.php
mod/workshop/lib.php

index 208a9ba..fd03337 100644 (file)
@@ -209,12 +209,23 @@ function edit_module_post_actions($moduleinfo, $course) {
             }
             $moduleinfo->gradecat = $grade_category->id;
         }
+        $gradecategory = $grade_item->get_parent_category();
         foreach ($items as $itemid=>$unused) {
             $items[$itemid]->set_parent($moduleinfo->gradecat);
             if ($itemid == $grade_item->id) {
                 // Use updated grade_item.
                 $grade_item = $items[$itemid];
             }
+            if (!empty($moduleinfo->add)) {
+                if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
+                    if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
+                        $grade_item->aggregationcoef = 1;
+                    } else {
+                        $grade_item->aggregationcoef = 0;
+                    }
+                    $grade_item->update();
+                }
+            }
         }
     }
 
@@ -273,6 +284,17 @@ function edit_module_post_actions($moduleinfo, $course) {
                 } else if (isset($moduleinfo->gradecat)) {
                     $outcome_item->set_parent($moduleinfo->gradecat);
                 }
+                $gradecategory = $outcome_item->get_parent_category();
+                if (!empty($moduleinfo->add)) {
+                    if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
+                        if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
+                            $outcome_item->aggregationcoef = 1;
+                        } else {
+                            $outcome_item->aggregationcoef = 0;
+                        }
+                        $outcome_item->update();
+                    }
+                }
             }
         }
     }
index 616bc4e..af9061c 100644 (file)
@@ -1141,6 +1141,17 @@ function workshop_grade_item_category_update($workshop) {
                     $gradeitem->set_parent($workshop->gradinggradecategory);
                 }
             }
+            if (!empty($workshop->add)) {
+                $gradecategory = $gradeitem->get_parent_category();
+                if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
+                    if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
+                        $gradeitem->aggregationcoef = 1;
+                    } else {
+                        $gradeitem->aggregationcoef = 0;
+                    }
+                    $gradeitem->update();
+                }
+            }
         }
     }
 }