mirror of
https://github.com/moodle/moodle.git
synced 2025-06-04 07:06:45 +02:00
MDL-33645 assign: Teachers should not be allowed to change grades if it is overridden in the gradebook
This commit is contained in:
parent
f8dfdb524b
commit
09b46f0e13
@ -340,8 +340,8 @@ class assign_grading_table extends table_sql implements renderable {
|
|||||||
$link = $this->output->action_link($url, $icon);
|
$link = $this->output->action_link($url, $icon);
|
||||||
$separator = $this->output->spacer(array(), true);
|
$separator = $this->output->spacer(array(), true);
|
||||||
}
|
}
|
||||||
|
$gradingdisabled = $this->assignment->grading_disabled($row->id);
|
||||||
$grade = $this->display_grade($row->grade, $this->quickgrading, $row->userid, $row->timemarked);
|
$grade = $this->display_grade($row->grade, $this->quickgrading && !$gradingdisabled, $row->userid, $row->timemarked);
|
||||||
|
|
||||||
//return $grade . $separator . $link;
|
//return $grade . $separator . $link;
|
||||||
return $link . $separator . $grade;
|
return $link . $separator . $grade;
|
||||||
|
@ -2169,15 +2169,14 @@ class assign {
|
|||||||
private function gradebook_item_update($submission=NULL, $grade=NULL) {
|
private function gradebook_item_update($submission=NULL, $grade=NULL) {
|
||||||
|
|
||||||
if($submission != NULL){
|
if($submission != NULL){
|
||||||
|
|
||||||
$gradebookgrade = $this->convert_submission_for_gradebook($submission);
|
$gradebookgrade = $this->convert_submission_for_gradebook($submission);
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
||||||
$gradebookgrade = $this->convert_grade_for_gradebook($grade);
|
$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 = clone $this->get_instance();
|
||||||
$assign->cmidnumber = $this->get_course_module()->id;
|
$assign->cmidnumber = $this->get_course_module()->id;
|
||||||
|
|
||||||
@ -2591,6 +2590,9 @@ class assign {
|
|||||||
}
|
}
|
||||||
if ($current->grade != $modified->grade) {
|
if ($current->grade != $modified->grade) {
|
||||||
// grade changed
|
// grade changed
|
||||||
|
if ($this->grading_disabled($modified->userid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ((int)$current->lastmodified > (int)$modified->lastmodified) {
|
if ((int)$current->lastmodified > (int)$modified->lastmodified) {
|
||||||
// error - record has been modified since viewing the page
|
// error - record has been modified since viewing the page
|
||||||
return get_string('errorrecordmodified', 'assign');
|
return get_string('errorrecordmodified', 'assign');
|
||||||
@ -2768,7 +2770,7 @@ class assign {
|
|||||||
* @param int $userid - The student userid
|
* @param int $userid - The student userid
|
||||||
* @return bool $gradingdisabled
|
* @return bool $gradingdisabled
|
||||||
*/
|
*/
|
||||||
private function grading_disabled($userid) {
|
public function grading_disabled($userid) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
|
$gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
|
||||||
@ -2856,14 +2858,20 @@ class assign {
|
|||||||
} else {
|
} else {
|
||||||
// use simple direct grading
|
// use simple direct grading
|
||||||
if ($this->get_instance()->grade > 0) {
|
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->addHelpButton('grade', 'gradeoutofhelp', 'assign');
|
||||||
$mform->setType('grade', PARAM_TEXT);
|
$mform->setType('grade', PARAM_TEXT);
|
||||||
|
if ($gradingdisabled) {
|
||||||
|
$gradingelement->freeze();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$grademenu = make_grades_menu($this->get_instance()->grade);
|
$grademenu = make_grades_menu($this->get_instance()->grade);
|
||||||
if (count($grademenu) > 0) {
|
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);
|
$mform->setType('grade', PARAM_INT);
|
||||||
|
if ($gradingdisabled) {
|
||||||
|
$gradingelement->freeze();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3115,6 +3123,9 @@ class assign {
|
|||||||
if (empty($CFG->enableoutcomes)) {
|
if (empty($CFG->enableoutcomes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($this->grading_disabled($userid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
require_once($CFG->libdir.'/gradelib.php');
|
require_once($CFG->libdir.'/gradelib.php');
|
||||||
|
|
||||||
@ -3175,12 +3186,14 @@ class assign {
|
|||||||
$grade = $this->get_user_grade($userid, true);
|
$grade = $this->get_user_grade($userid, true);
|
||||||
$gradingdisabled = $this->grading_disabled($userid);
|
$gradingdisabled = $this->grading_disabled($userid);
|
||||||
$gradinginstance = $this->get_grading_instance($userid, $gradingdisabled);
|
$gradinginstance = $this->get_grading_instance($userid, $gradingdisabled);
|
||||||
if ($gradinginstance) {
|
if (!$gradingdisabled) {
|
||||||
$grade->grade = $gradinginstance->submit_and_get_grade($formdata->advancedgrading, $grade->id);
|
if ($gradinginstance) {
|
||||||
} else {
|
$grade->grade = $gradinginstance->submit_and_get_grade($formdata->advancedgrading, $grade->id);
|
||||||
// handle the case when grade is set to No Grade
|
} else {
|
||||||
if (isset($formdata->grade)) {
|
// handle the case when grade is set to No Grade
|
||||||
$grade->grade= grade_floatval(unformat_float($formdata->grade));
|
if (isset($formdata->grade)) {
|
||||||
|
$grade->grade = grade_floatval(unformat_float($formdata->grade));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$grade->grader= $USER->id;
|
$grade->grader= $USER->id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user