diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php index b214864b090..042af511984 100644 --- a/mod/assign/lang/en/assign.php +++ b/mod/assign/lang/en/assign.php @@ -187,6 +187,7 @@ $string['graded'] = 'Graded'; $string['gradedon'] = 'Graded on'; $string['gradebelowzero'] = 'Grade must be greater than or equal to zero.'; $string['gradeabovemaximum'] = 'Grade must be less than or equal to {$a}.'; +$string['gradelocked'] = 'This grade is locked or overridden in the gradebook.'; $string['gradeoutof'] = 'Grade out of {$a}'; $string['gradeoutofhelp'] = 'Grade'; $string['gradeoutofhelp_help'] = 'Enter the grade for the student\'s submission here. You may include decimals.'; diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index fed15b25c2c..e472da5d5f7 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -4086,7 +4086,15 @@ class assign { } } - if ($this->grading_disabled($userid, false)) { + // See if this user grade is locked in the gradebook. + $gradinginfo = grade_get_grades($this->get_course()->id, + 'mod', + 'assign', + $this->get_instance()->id, + array($userid)); + if ($gradinginfo && + isset($gradinginfo->items[0]->grades[$userid]) && + $gradinginfo->items[0]->grades[$userid]->locked) { return false; } @@ -5137,7 +5145,7 @@ class assign { /** - * Determine if this users grade is locked or overridden. + * Determine if this users grade can be edited. * * @param int $userid - The student userid * @param bool $checkworkflow - whether to include a check for the workflow state. @@ -5271,11 +5279,17 @@ class assign { // Use simple direct grading. if ($this->get_instance()->grade > 0) { $name = get_string('gradeoutof', 'assign', $this->get_instance()->grade); - $gradingelement = $mform->addElement('text', 'grade', $name); - $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign'); - $mform->setType('grade', PARAM_TEXT); - if ($gradingdisabled) { - $gradingelement->freeze(); + if (!$gradingdisabled) { + $gradingelement = $mform->addElement('text', 'grade', $name); + $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign'); + $mform->setType('grade', PARAM_RAW); + } else { + $mform->addElement('hidden', 'grade', $name); + $mform->hardFreeze('grade'); + $mform->setType('grade', PARAM_RAW); + $strgradelocked = get_string('gradelocked', 'assign'); + $mform->addElement('static', 'gradedisabled', $name, $strgradelocked); + $mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign'); } } else { $grademenu = make_grades_menu($this->get_instance()->grade);