Permalink
Browse files

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

… an assignment submission
  • Loading branch information...
1 parent a322a0a commit a10d621fc50e5fdceb5dec4df8dd04ba10387a55 @steelej steelej committed with marinaglancy Oct 16, 2013
Showing with 8 additions and 4 deletions.
  1. +1 −1 mod/assign/gradeform.php
  2. +7 −3 mod/assign/locallib.php
View
@@ -95,7 +95,7 @@ function validation($data, $files) {
// this is a scale
if ($scale = $DB->get_record('scale', array('id'=>-($this->assignment->get_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
@@ -3110,6 +3110,10 @@ private 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;
@@ -4243,9 +4247,9 @@ 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) {
- $gradingelement = $mform->addElement('select', 'grade', get_string('grade').':', $grademenu);
+ $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.
if (!empty($data->grade)) {

0 comments on commit a10d621

Please sign in to comment.