MDL-47064 core_grades: fix the calculation of contribution towards total
authorSimey Lameze <simey@moodle.com>
Mon, 15 Sep 2014 04:19:40 +0000 (12:19 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 3 Oct 2014 05:54:39 +0000 (13:54 +0800)
Part of: MDL-46576

grade/report/user/lib.php

index 3034db7..8718150 100644 (file)
@@ -655,7 +655,11 @@ class grade_report_user extends grade_report {
                                 }
                             }
                             if ($validpercent) {
-                                $data['contributiontocoursetotal']['content'] = format_float($percentoftotal * 100.0, 2) . ' %';
+                                $grademin = $grade_grade->grade_item->grademin;
+                                $grademax = $grade_grade->grade_item->grademax;
+                                $finalgrade = $grade_grade->finalgrade;
+                                $contribution = format_float(((($finalgrade-$grademin)/($grademax-$grademin)*($percentoftotal * 100.0))),2);
+                                $data['contributiontocoursetotal']['content'] = $contribution;
                             }
                         }
                     }