Permalink
Browse files

MDL-30061: advanced grading evaluation freezes now if grade is locked…

… or overriden
  • Loading branch information...
1 parent 050125d commit 71380f2f146fc08378776a19df377577827c26c5 @marinaglancy marinaglancy committed Nov 8, 2011
Showing with 19 additions and 5 deletions.
  1. +19 −5 mod/assignment/lib.php
View
@@ -1078,8 +1078,12 @@ function display_submission($offset=-1,$userid =-1, $display=true) {
if (!empty($submission->id)) {
$itemid = $submission->id;
}
- $instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
- $mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
+ if ($gradingdisabled && $itemid) {
+ $mformdata->advancedgradinginstance = $controller->get_current_instance($USER->id, $itemid);
+ } else if (!$gradingdisabled) {
+ $instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
+ $mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
+ }
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
}
@@ -1605,12 +1609,18 @@ function display_submissions($message='') {
* If validation passes, preprocess advanced grading (if applicable) and returns true.
*/
function validate_and_preprocess_feedback() {
- global $USER;
+ global $USER, $CFG;
+ require_once($CFG->libdir.'/gradelib.php');
if (!($feedback = data_submitted()) || !isset($feedback->userid) || !isset($feedback->offset)) {
return true; // No incoming data, nothing to validate
}
$userid = required_param('userid', PARAM_INT);
$offset = required_param('offset', PARAM_INT);
+ $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($userid));
+ $gradingdisabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
+ if ($gradingdisabled) {
+ return true;
+ }
$submissiondata = $this->display_submission($offset, $userid, false);
$mform = $submissiondata->mform;
$gradinginstance = $mform->use_advanced_grading();
@@ -2391,9 +2401,13 @@ function add_grades_section() {
$grademenu = make_grades_menu($this->_customdata->assignment->grade);
if ($gradinginstance = $this->use_advanced_grading()) {
- $mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
$gradinginstance->get_controller()->set_grade_range($grademenu);
- $mform->addElement('grading', 'advancedgrading', get_string('grade').':', array('gradinginstance' => $gradinginstance));
+ $gradingelement = $mform->addElement('grading', 'advancedgrading', get_string('grade').':', array('gradinginstance' => $gradinginstance));
+ if ($this->_customdata->gradingdisabled) {
+ $gradingelement->freeze();
+ } else {
+ $mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
+ }
} else {
// use simple direct grading
$grademenu['-1'] = get_string('nograde');

0 comments on commit 71380f2

Please sign in to comment.