]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12517, notify when grades entered into gradebook is out of bounds
authortoyomoyo <toyomoyo>
Thu, 13 Dec 2007 07:09:27 +0000 (07:09 +0000)
committertoyomoyo <toyomoyo>
Thu, 13 Dec 2007 07:09:27 +0000 (07:09 +0000)
lang/en_utf8/grades.php
lib/grade/grade_item.php

index 575e34ee677fb3a7d9de5db3932cf5ab2503b91f..9e94949cd72bac06946562e216b7176ee64798bd 100644 (file)
@@ -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.';
index 2794ff4134e2dc0106e477d4790e9ac5d92310a6..e8d531d6dd5ec31270b28c2c66b406ee372be541 100644 (file)
@@ -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);
             }
         }