From 3c46f7e1b92e868155d88ececcdb9c46f32c99aa Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 15 Sep 2014 12:19:40 +0800 Subject: [PATCH] MDL-47064 core_grades: fix the calculation of contribution towards total Part of: MDL-46576 --- grade/report/user/lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index 3034db742e9..871815041a0 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -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; } } }