mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-51584 gradebook: use direct $CFG access for freeze.
get_config() is called a lot of times on freeze and is expensive, using $CFG is much lower overhead.
This commit is contained in:
parent
d9520bc04e
commit
82905c097c
@ -996,6 +996,8 @@ class grade_category extends grade_object {
|
||||
& $weights = null,
|
||||
$grademinoverrides = array(),
|
||||
$grademaxoverrides = array()) {
|
||||
global $CFG;
|
||||
|
||||
$category_item = $this->load_grade_item();
|
||||
$grademin = $category_item->grademin;
|
||||
$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.
|
||||
// Even though old algorith has bugs in it, we need to preserve existing grades.
|
||||
$gradebookcalculationfreeze = (int)get_config('core', 'gradebook_calculations_freeze_' . $this->courseid);
|
||||
$oldextracreditcalculation = $gradebookcalculationfreeze && ($gradebookcalculationfreeze <= 20150619);
|
||||
$gradebookcalculationfreeze = 'gradebook_calculations_freeze_' . $this->courseid;
|
||||
$oldextracreditcalculation = isset($CFG->$gradebookcalculationfreeze)
|
||||
&& ($CFG->$gradebookcalculationfreeze <= 20150619);
|
||||
|
||||
$sumweights = 0;
|
||||
$grademin = 0;
|
||||
@ -1479,7 +1482,7 @@ class grade_category extends grade_object {
|
||||
* @return void
|
||||
*/
|
||||
private function auto_update_max() {
|
||||
global $DB;
|
||||
global $CFG, $DB;
|
||||
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
|
||||
// not needed at all
|
||||
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
|
||||
// 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.
|
||||
if ($gradebookcalculationsfreeze && (int)$gradebookcalculationsfreeze <= 20150627) {
|
||||
// Do nothing.
|
||||
} else{
|
||||
if (!$oldextracreditcalculation) {
|
||||
// Don't automatically update the max for calculated items.
|
||||
if ($this->grade_item->is_calculated()) {
|
||||
return;
|
||||
|
@ -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
|
||||
// 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.
|
||||
if ($gradebookcalculationsfreeze && (int)$gradebookcalculationsfreeze <= 20150627) {
|
||||
if (isset($CFG->$gradebookcalculationsfreeze) && (int)$CFG->$gradebookcalculationsfreeze <= 20150627) {
|
||||
// Only aggregate items use separate min grades.
|
||||
if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE || $this->grade_item->is_aggregate_item()) {
|
||||
return array($this->rawgrademin, $this->rawgrademax);
|
||||
|
Loading…
x
Reference in New Issue
Block a user