MDL-47064 Grades: Final fix - set the grademax from the item, not the cat
authorDamyon Wiese <damyon@moodle.com>
Thu, 25 Sep 2014 01:44:00 +0000 (09:44 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 3 Oct 2014 05:55:23 +0000 (13:55 +0800)
Part of: MDL-46576

grade/report/user/lib.php
lib/grade/grade_category.php
lib/grade/grade_grade.php

index 7fe7d59..fad11d7 100644 (file)
@@ -461,7 +461,7 @@ class grade_report_user extends grade_report {
 
                 /// Actual Grade
                 $gradeval = $grade_grade->finalgrade;
-                $hint = $grade_grade->get_aggregation_hint($grade_object);
+                $hint = $grade_grade->get_aggregation_hint();
                 if (!$this->canviewhidden) {
                     /// Virtual Grade (may be calculated excluding hidden items etc).
                     $adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid,
index cd62e56..b73d96e 100644 (file)
@@ -613,7 +613,7 @@ class grade_category extends grade_object {
 
             $notexisting = array_diff(array_keys($items), array_keys($existingitems));
             foreach ($notexisting as $itemid) {
-                $gradeitem = $this->grade_item;
+                $gradeitem = $items[$itemid];
                 $gradegrade = new grade_grade(array('itemid' => $itemid,
                                                     'userid' => $userid,
                                                     'rawgrademin' => $gradeitem->grademin,
index 430fbbb..be9ee40 100644 (file)
@@ -320,7 +320,7 @@ class grade_grade extends grade_object {
     /**
      * Returns the info on how this value was used in the aggregated grade
      *
-     * @return string One of 'dropped', 'excluded', 'novalue' or a specific weighting
+     * @return string One of 'dropped', 'excluded', 'novalue', 'used' or 'extra'
      */
     public function get_aggregationstatus() {
         return $this->aggregationstatus;
@@ -786,7 +786,7 @@ class grade_grade extends grade_object {
                                 if ($grade_grades[$itemid]->is_excluded()) {
                                     unset($values[$itemid]);
                                     $alteredaggregationstatus[$itemid] = 'excluded';
-                                    $alteredaggregationweight[$itemid] = 0;
+                                    $alteredaggregationweight[$itemid] = null;
                                     continue;
                                 }
                                 // The grade min/max may have been altered by hiding.
@@ -806,7 +806,7 @@ class grade_grade extends grade_object {
                                     if (is_null($value)) {
                                         unset($values[$itemid]);
                                         $alteredaggregationstatus[$itemid] = 'novalue';
-                                        $alteredaggregationweight[$itemid] = 0;
+                                        $alteredaggregationweight[$itemid] = null;
                                     }
                                 }
                             } else {
@@ -824,7 +824,7 @@ class grade_grade extends grade_object {
                             $moredropped = array_diff($allvalues, $values);
                             foreach ($moredropped as $drop => $unused) {
                                 $alteredaggregationstatus[$drop] = 'dropped';
-                                $alteredaggregationweight[$drop] = 0;
+                                $alteredaggregationweight[$drop] = null;
                             }
 
                             foreach ($values as $itemid => $val) {
@@ -1019,12 +1019,10 @@ class grade_grade extends grade_object {
      * for the grade_category. For example this could be an extra credit item, and it could be
      * dropped because it's in the X lowest or highest.
      *
-     * @param grade_item $gradeitem An optional grade_item, saves having to load the grade_grade's grade_item
      * @return array(status, weight) - A keyword and a numerical weight that represents how this grade was included in the aggregation.
      */
-    function get_aggregation_hint($gradeitem = null) {
-
+    function get_aggregation_hint() {
         return array('status' => $this->get_aggregationstatus(),
-                     'weight' => $this->aggregationweight);
+                     'weight' => $this->get_aggregationweight());
     }
 }