MDL-34989 assign: Do not add a param to grading_disabled - cannot be backported.
authorDamyon Wiese <damyon@moodle.com>
Mon, 29 Jul 2013 01:27:41 +0000 (09:27 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 29 Jul 2013 01:55:46 +0000 (09:55 +0800)
mod/assign/locallib.php

index 240f453..e472da5 100644 (file)
@@ -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.
@@ -5274,10 +5282,11 @@ class assign {
                 if (!$gradingdisabled) {
                     $gradingelement = $mform->addElement('text', 'grade', $name);
                     $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
-                    $mform->setType('grade', PARAM_TEXT);
+                    $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');