Permalink
Browse files

MDL-33645 assign: Teachers should not be allowed to change grades if …

…it is overridden in the gradebook
  • Loading branch information...
1 parent f8dfdb5 commit 09b46f0e13de9bf1c7b3f106ff96e6146e7b246d @ankitagarwal ankitagarwal committed Jun 12, 2012
Showing with 29 additions and 16 deletions.
  1. +2 −2 mod/assign/gradingtable.php
  2. +27 −14 mod/assign/locallib.php
@@ -340,8 +340,8 @@ function col_grade(stdClass $row) {
$link = $this->output->action_link($url, $icon);
$separator = $this->output->spacer(array(), true);
}
-
- $grade = $this->display_grade($row->grade, $this->quickgrading, $row->userid, $row->timemarked);
+ $gradingdisabled = $this->assignment->grading_disabled($row->id);
+ $grade = $this->display_grade($row->grade, $this->quickgrading && !$gradingdisabled, $row->userid, $row->timemarked);
//return $grade . $separator . $link;
return $link . $separator . $grade;
@@ -2169,15 +2169,14 @@ private function convert_submission_for_gradebook(stdClass $submission) {
private function gradebook_item_update($submission=NULL, $grade=NULL) {
if($submission != NULL){
-
$gradebookgrade = $this->convert_submission_for_gradebook($submission);
-
-
}else{
-
-
$gradebookgrade = $this->convert_grade_for_gradebook($grade);
}
+ // Grading is disabled, return.
+ if ($this->grading_disabled($gradebookgrade['userid'])) {
+ return false;
+ }
$assign = clone $this->get_instance();
$assign->cmidnumber = $this->get_course_module()->id;
@@ -2591,6 +2590,9 @@ private function process_save_quick_grades() {
}
if ($current->grade != $modified->grade) {
// grade changed
+ if ($this->grading_disabled($modified->userid)) {
+ continue;
+ }
if ((int)$current->lastmodified > (int)$modified->lastmodified) {
// error - record has been modified since viewing the page
return get_string('errorrecordmodified', 'assign');
@@ -2768,7 +2770,7 @@ private function process_save_submission(&$mform) {
* @param int $userid - The student userid
* @return bool $gradingdisabled
*/
- private function grading_disabled($userid) {
+ public function grading_disabled($userid) {
global $CFG;
$gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
@@ -2856,14 +2858,20 @@ public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data,
} else {
// use simple direct grading
if ($this->get_instance()->grade > 0) {
- $mform->addElement('text', 'grade', get_string('gradeoutof', 'assign',$this->get_instance()->grade));
+ $gradingelement = $mform->addElement('text', 'grade', get_string('gradeoutof', 'assign',$this->get_instance()->grade));
$mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
$mform->setType('grade', PARAM_TEXT);
+ if ($gradingdisabled) {
+ $gradingelement->freeze();
+ }
} else {
$grademenu = make_grades_menu($this->get_instance()->grade);
if (count($grademenu) > 0) {
- $mform->addElement('select', 'grade', get_string('grade').':', $grademenu);
+ $gradingelement = $mform->addElement('select', 'grade', get_string('grade').':', $grademenu);
$mform->setType('grade', PARAM_INT);
+ if ($gradingdisabled) {
+ $gradingelement->freeze();
+ }
}
}
}
@@ -3115,6 +3123,9 @@ private function process_outcomes($userid, $formdata) {
if (empty($CFG->enableoutcomes)) {
return;
}
+ if ($this->grading_disabled($userid)) {
+ return;
+ }
require_once($CFG->libdir.'/gradelib.php');
@@ -3175,12 +3186,14 @@ private function process_save_grade(&$mform) {
$grade = $this->get_user_grade($userid, true);
$gradingdisabled = $this->grading_disabled($userid);
$gradinginstance = $this->get_grading_instance($userid, $gradingdisabled);
- if ($gradinginstance) {
- $grade->grade = $gradinginstance->submit_and_get_grade($formdata->advancedgrading, $grade->id);
- } else {
- // handle the case when grade is set to No Grade
- if (isset($formdata->grade)) {
- $grade->grade= grade_floatval(unformat_float($formdata->grade));
+ if (!$gradingdisabled) {
+ if ($gradinginstance) {
+ $grade->grade = $gradinginstance->submit_and_get_grade($formdata->advancedgrading, $grade->id);
+ } else {
+ // handle the case when grade is set to No Grade
+ if (isset($formdata->grade)) {
+ $grade->grade = grade_floatval(unformat_float($formdata->grade));
+ }
}
}
$grade->grader= $USER->id;

0 comments on commit 09b46f0

Please sign in to comment.