# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: moodle/lib/grade/grade_category.php --- moodle/lib/grade/grade_category.php Base (1.96.2.22) +++ moodle/lib/grade/grade_category.php Locally Modified (Based On 1.96.2.22) @@ -567,7 +567,7 @@ if (is_null($finalgrade)) { $grade->finalgrade = null; } else { - $grade->finalgrade = (float)bounded_number($this->grade_item->grademin, $finalgrade, $this->grade_item->grademax); + $grade->finalgrade = (float)bounded_number($this->grade_item->grademin, $finalgrade, $this->grade_item->grademax*$CFG->grade_over100factor); } // update in db if changed @@ -697,6 +697,7 @@ * @return boolean (just plain return;) */ function sum_grades(&$grade, $oldfinalgrade, $items, $grade_values, $excluded) { + global $CFG; if (empty($items)) { return null; } @@ -744,7 +745,7 @@ $this->apply_limit_rules($grade_values); $sum = array_sum($grade_values); - $grade->finalgrade = bounded_number($this->grade_item->grademin, $sum, $this->grade_item->grademax); + $grade->finalgrade = bounded_number($this->grade_item->grademin, $sum, $this->grade_item->grademax*$CFG->grade_over100factor); // update in db if changed if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) { Index: moodle/lib/grade/grade_grade.php --- moodle/lib/grade/grade_grade.php Base (1.14.2.18) +++ moodle/lib/grade/grade_grade.php Locally Modified (Based On 1.14.2.18) @@ -668,7 +668,7 @@ $finalgrade = grade_grade::standardise_score($agg_grade, 0, 1, $grade_items[$do]->grademin, $grade_items[$do]->grademax); if (!is_null($finalgrade)) { - $finalgrade = bounded_number($grade_items[$do]->grademin, $finalgrade, $grade_items[$do]->grademax); + $finalgrade = bounded_number($grade_items[$do]->grademin, $finalgrade, $grade_items[$do]->grademax*$CFG->grade_over100factor); } $altered[$do] = $finalgrade; Index: moodle/lib/grade/grade_item.php --- moodle/lib/grade/grade_item.php Base (1.130.2.29) +++ moodle/lib/grade/grade_item.php Locally Modified (Based On 1.130.2.29) @@ -716,6 +716,7 @@ * @return mixed */ function adjust_raw_grade($rawgrade, $rawmin, $rawmax) { + global $CFG; if (is_null($rawgrade)) { return null; } @@ -740,7 +741,7 @@ $rawgrade *= $this->multfactor; $rawgrade += $this->plusfactor; - return bounded_number($this->grademin, $rawgrade, $this->grademax); + return bounded_number($this->grademin, $rawgrade, $this->grademax*$CFG->grade_over100factor); } else if ($this->gradetype == GRADE_TYPE_SCALE) { // Dealing with a scale value if (empty($this->scale)) { @@ -1396,7 +1397,7 @@ if (is_null($finalgrade)) { $grade->finalgrade = null; } else { - $grade->finalgrade = bounded_number($this->grademin, $finalgrade, $this->grademax); + $grade->finalgrade = bounded_number($this->grademin, $finalgrade, $this->grademax*$CFG->grade_over100factor); } } @@ -1696,6 +1697,7 @@ * internal function - does the final grade calculation */ function use_formula($userid, $params, $useditems, $oldgrade) { + global $CFG; if (empty($userid)) { return true; } @@ -1740,7 +1742,7 @@ } else { // normalize - $result = bounded_number($this->grademin, $result, $this->grademax); + $result = bounded_number($this->grademin, $result, $this->grademax*$CFG->grade_over100factor); if ($this->gradetype == GRADE_TYPE_SCALE) { $result = round($result+0.00001); // round scales upwards } Index: moodle/lib/gradelib.php --- moodle/lib/gradelib.php Base (1.120.2.27) +++ moodle/lib/gradelib.php Locally Modified (Based On 1.120.2.27) @@ -715,12 +715,13 @@ } function grade_format_gradevalue_percentage($value, $grade_item, $decimals, $localized) { + global $CFG; $min = $grade_item->grademin; $max = $grade_item->grademax; if ($min == $max) { return ''; } - $value = bounded_number($min, $value, $max); + $value = bounded_number($min, $value, $max*$CFG->grade_over100factor); $percentage = (($value-$min)*100)/($max-$min); return format_float($percentage, $decimals, $localized).' %'; } Index: moodle/lib/setup.php --- moodle/lib/setup.php Base (1.212.2.24) +++ moodle/lib/setup.php Locally Modified (Based On 1.212.2.24) @@ -779,6 +779,12 @@ } } +/// Setting $CFG->grade_over100factor in config.php to a value greater than 1 +/// allows grades to exceed 100% by that factor. MDL-12380 + if (empty($CFG->grade_over100factor) || $CFG->grade_over100factor < 1 ) { + $CFG->grade_over100factor = 1; + } + /// note: we can not block non utf-8 installatrions here, because empty mysql database /// might be converted to utf-8 in admin/index.php during installation ?>