Merge branch 'MDL-49281-master' of git://github.com/mastnym/moodle
authorDavid Monllao <davidm@moodle.com>
Thu, 30 Apr 2015 06:53:52 +0000 (14:53 +0800)
committerDavid Monllao <davidm@moodle.com>
Thu, 30 Apr 2015 06:53:52 +0000 (14:53 +0800)
grade/edit/tree/lib.php

index dcafa70..a2bc4f4 100644 (file)
@@ -136,8 +136,11 @@ class grade_edit_tree {
         if (!$is_category_item && ($icon = $this->gtree->get_edit_icon($element, $this->gpr, true))) {
             $actionsmenu->add($icon);
         }
-
-        if ($this->show_calculations && ($icon = $this->gtree->get_calculation_icon($element, $this->gpr, true))) {
+        // MDL-49281 if grade_item already has calculation, it should be editable even if global setting is off.
+        $type = $element['type'];
+        $iscalculated = ($type == 'item' or $type == 'courseitem' or $type == 'categoryitem') && $object->is_calculated();
+        $icon = $this->gtree->get_calculation_icon($element, $this->gpr, true);
+        if ($iscalculated || ($this->show_calculations && $icon)) {
             $actionsmenu->add($icon);
         }