From 13cd3572efcc970990dd5f5f01d5f54eac766ef2 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 27 Feb 2009 13:05:58 +0000 Subject: [PATCH] MDL-18402 Setting aggregationcoef to 1 if left empty --- lib/grade/grade_item.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 192e247b0dc..bb808add159 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -247,6 +247,7 @@ class grade_item extends grade_object { * In addition to update() as defined in grade_object, handle the grade_outcome and grade_scale objects. * Force regrading if necessary, rounds the float numbers using php function, * the reason is we need to compare the db value with computed number to skip regrading if possible. + * Also sets aggregationcoef to 1 if unset: 0 would negate it in the mean * @param string $source from where was the object inserted (mod/forum, manual, etc.) * @return boolean success */ @@ -268,6 +269,10 @@ class grade_item extends grade_object { $this->timemodified = time(); + if (is_null($this->aggregationcoef)) { + $this->aggregationcoef = 1; + } + $this->grademin = grade_floatval($this->grademin); $this->grademax = grade_floatval($this->grademax); $this->multfactor = grade_floatval($this->multfactor); @@ -1878,7 +1883,7 @@ class grade_item extends grade_object { global $USER; // Determine which display type to use for this average - if ($USER->gradeediting[$this->courseid]) { + if (isset($USER->gradeediting) && $USER->gradeediting[$this->courseid]) { $displaytype = GRADE_DISPLAY_TYPE_REAL; } else if ($rangesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave report and user prefs