This commit is contained in:
Dan Poltawski 2016-10-10 13:23:59 +01:00
commit 0b7aef7b20
2 changed files with 11 additions and 9 deletions

View file

@ -996,6 +996,8 @@ class grade_category extends grade_object {
& $weights = null, & $weights = null,
$grademinoverrides = array(), $grademinoverrides = array(),
$grademaxoverrides = array()) { $grademaxoverrides = array()) {
global $CFG;
$category_item = $this->load_grade_item(); $category_item = $this->load_grade_item();
$grademin = $category_item->grademin; $grademin = $category_item->grademin;
$grademax = $category_item->grademax; $grademax = $category_item->grademax;
@ -1283,8 +1285,9 @@ class grade_category extends grade_object {
// This setting indicates if we should use algorithm prior to MDL-49257 fix for calculating extra credit weights. // This setting indicates if we should use algorithm prior to MDL-49257 fix for calculating extra credit weights.
// Even though old algorith has bugs in it, we need to preserve existing grades. // Even though old algorith has bugs in it, we need to preserve existing grades.
$gradebookcalculationfreeze = (int)get_config('core', 'gradebook_calculations_freeze_' . $this->courseid); $gradebookcalculationfreeze = 'gradebook_calculations_freeze_' . $this->courseid;
$oldextracreditcalculation = $gradebookcalculationfreeze && ($gradebookcalculationfreeze <= 20150619); $oldextracreditcalculation = isset($CFG->$gradebookcalculationfreeze)
&& ($CFG->$gradebookcalculationfreeze <= 20150619);
$sumweights = 0; $sumweights = 0;
$grademin = 0; $grademin = 0;
@ -1479,7 +1482,7 @@ class grade_category extends grade_object {
* @return void * @return void
*/ */
private function auto_update_max() { private function auto_update_max() {
global $DB; global $CFG, $DB;
if ($this->aggregation != GRADE_AGGREGATE_SUM) { if ($this->aggregation != GRADE_AGGREGATE_SUM) {
// not needed at all // not needed at all
return; return;
@ -1491,11 +1494,10 @@ class grade_category extends grade_object {
// Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they
// wish to update the grades. // wish to update the grades.
$gradebookcalculationsfreeze = get_config('core', 'gradebook_calculations_freeze_' . $this->courseid); $gradebookcalculationfreeze = 'gradebook_calculations_freeze_' . $this->courseid;
$oldextracreditcalculation = isset($CFG->$gradebookcalculationfreeze) && ($CFG->$gradebookcalculationfreeze <= 20150627);
// Only run if the gradebook isn't frozen. // Only run if the gradebook isn't frozen.
if ($gradebookcalculationsfreeze && (int)$gradebookcalculationsfreeze <= 20150627) { if (!$oldextracreditcalculation) {
// Do nothing.
} else{
// Don't automatically update the max for calculated items. // Don't automatically update the max for calculated items.
if ($this->grade_item->is_calculated()) { if ($this->grade_item->is_calculated()) {
return; return;

View file

@ -352,9 +352,9 @@ class grade_grade extends grade_object {
// Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they
// wish to update the grades. // wish to update the grades.
$gradebookcalculationsfreeze = get_config('core', 'gradebook_calculations_freeze_' . $this->grade_item->courseid); $gradebookcalculationsfreeze = 'gradebook_calculations_freeze_' . $this->grade_item->courseid;
// Gradebook is frozen, run through old code. // Gradebook is frozen, run through old code.
if ($gradebookcalculationsfreeze && (int)$gradebookcalculationsfreeze <= 20150627) { if (isset($CFG->$gradebookcalculationsfreeze) && (int)$CFG->$gradebookcalculationsfreeze <= 20150627) {
// Only aggregate items use separate min grades. // Only aggregate items use separate min grades.
if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE || $this->grade_item->is_aggregate_item()) { if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE || $this->grade_item->is_aggregate_item()) {
return array($this->rawgrademin, $this->rawgrademax); return array($this->rawgrademin, $this->rawgrademax);