MDL-12517, notify when grades entered into gradebook is out of bounds
This commit is contained in:
@@ -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.';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user