Permalink
Browse files

MDL-38628 mod_assign: Allow a user to specify "No Grade" when grading…

… an assignment submission
  • Loading branch information...
1 parent e4ffd3d commit add50b5ab0c237c951e6392e0e447e394c91f4f8 @steelej steelej committed with marinaglancy Oct 16, 2013
Showing with 7 additions and 3 deletions.
  1. +1 −1 mod/assign/gradeform.php
  2. +6 −2 mod/assign/locallib.php
View
@@ -94,7 +94,7 @@ public function validation($data, $files) {
// This is a scale.
if ($scale = $DB->get_record('scale', array('id'=>-($instance->grade)))) {
$scaleoptions = make_menu_from_list($scale->scale);
- if (!array_key_exists((int)$data['grade'], $scaleoptions)) {
+ if ((int)$data['grade'] !== -1 && !array_key_exists((int)$data['grade'], $scaleoptions)) {
$errors['grade'] = get_string('invalidgradeforscale', 'assign');
}
}
View
@@ -3909,6 +3909,10 @@ protected function convert_grade_for_gradebook(stdClass $grade) {
if ($grade->grade >= 0) {
$gradebookgrade['rawgrade'] = $grade->grade;
}
+ // Allow "no grade" to be chosen.
+ if ($grade->grade == -1) {
+ $gradebookgrade['rawgrade'] = NULL;
+ }
$gradebookgrade['userid'] = $grade->userid;
$gradebookgrade['usermodified'] = $grade->grader;
$gradebookgrade['datesubmitted'] = null;
@@ -5520,8 +5524,8 @@ public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data,
$mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign');
}
} else {
- $grademenu = make_grades_menu($this->get_instance()->grade);
- if (count($grademenu) > 0) {
+ $grademenu = array(-1 => get_string("nograde")) + make_grades_menu($this->get_instance()->grade);
+ if (count($grademenu) > 1) {
$gradingelement = $mform->addElement('select', 'grade', get_string('grade') . ':', $grademenu);
// The grade is already formatted with format_float so it needs to be converted back to an integer.

0 comments on commit add50b5

Please sign in to comment.