Skip to content

Commit

Permalink
MDL-12517 - Move checking code into the user interface layer where it…
Browse files Browse the repository at this point in the history
… belongs. Merged from MOODLE_19_STABLE.
  • Loading branch information
tjhunt committed Dec 13, 2007
1 parent 56af043 commit 0a2c848
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 14 additions & 0 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ function process_data($data) {
$finalgrade = unformat_float($postedvalue);
}

// Warn if the grade is out of bounds.
$errorstr = '';
if ($finalgrade < $grade_item->grademax) {
$errorstr = 'lessthanmin';
} else if ($finalgrade > $grade_item->grademax) {
$errorstr = 'morethanmax';
}
if ($errorstr) {
$user = get_record('user', 'id', $userid,'','','','','id, firstname, lastname');
$gradestr->username = fullname($user);
$gradestr->itemname = $grade_item->get_name();
notify(get_string($errorstr, 'grades', $gradestr));
}

} else if ($data_type == 'feedback') {
$finalgrade = false;
$trimmed = trim($postedvalue);
Expand Down
12 changes: 0 additions & 12 deletions lib/grade/grade_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -1366,18 +1366,6 @@ function update_final_grade($userid, $finalgrade=false, $source=NULL, $feedback=
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);
}
}
Expand Down

0 comments on commit 0a2c848

Please sign in to comment.