From: toyomoyo Date: Thu, 13 Dec 2007 07:09:27 +0000 (+0000) Subject: MDL-12517, notify when grades entered into gradebook is out of bounds X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=56af043f38f8a12de81a11d3fa039d80e6d835e3;p=moodle.git MDL-12517, notify when grades entered into gradebook is out of bounds --- diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 575e34ee67..9e94949cd7 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -267,6 +267,7 @@ $string['itemsedit'] = 'Edit grade item'; $string['keephigh'] = 'Keep the highest'; $string['keephighhelp'] = 'If set, this option will only keep the X highest grades, X being the selected value for this option.'; $string['keymanager'] = 'Key manager'; +$string['lessthanmin'] = 'grade entered for $a->itemname for $a->username is less than the minimum allowed'; $string['lettergrade'] = 'Letter grade'; $string['lettergradenonnumber'] = 'Low and/or High grade were non-numeric for'; $string['letter'] = 'Letter'; @@ -293,6 +294,7 @@ $string['median'] = 'Median'; $string['min'] = 'Lowest'; $string['missingscale'] = 'Scale must be selected'; $string['mode'] = 'Mode'; +$string['morethanmax'] = 'grade entered for $a->itemname for $a->username is more than the maximum allowed'; $string['movingelement'] = 'Moving $a'; $string['multfactor'] = 'Multiplicator'; $string['multfactorhelp'] = 'Factor by which all grades for this grade item will be multiplied.'; diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 2794ff4134..e8d531d6dd 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -1366,6 +1366,18 @@ class grade_item extends grade_object { if (is_null($finalgrade)) { $grade->finalgrade = null; } else { + // MDL-12517, warn user if grade is out of bounds + if ($finalgrade < $this->grademin) { + $user = get_record('user', 'id', $grade->userid,'','','','','id, firstname, lastname'); + $gradestr->username = fullname($user); + $gradestr->itemname = $this->get_name(); + notify(get_string('lessthanmin', 'grades', $gradestr)); + } else if ($finalgrade > $this->grademax) { + $user = get_record('user', 'id', $grade->userid,'','','','','id, firstname, lastname'); + $gradestr->username = fullname($user); + $gradestr->itemname = $this->get_name(); + notify(get_string('morethanmax', 'grades', $gradestr)); + } $grade->finalgrade = (float)bounded_number($this->grademin, $finalgrade, $this->grademax); } }