Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-36090 core_grade: added logging of overriding of student grades

  • Loading branch information...
commit f2f5e4dd448cfa9aebdf5dfd5d1b6e1da780520f 1 parent ee2e56e
@andyjdavis andyjdavis authored
View
3  backup/moodle2/restore_final_task.class.php
@@ -143,6 +143,9 @@ static public function define_restore_log_rules() {
$rules[] = new restore_log_rule('course', 'report stats', 'report/stats/index.php?id={course}', '{course}');
$rules[] = new restore_log_rule('course', 'view section', 'view.php?id={course}&sectionid={course_section}', '{course_section}');
+ // module 'grade' rules
+ $rules[] = new restore_log_rule('grade', 'update', 'report/grader/index.php?id={course}', null);
+
// module 'user' rules
$rules[] = new restore_log_rule('user', 'view', 'view.php?id={user}&course={course}', '{user}');
$rules[] = new restore_log_rule('user', 'change password', 'view.php?id={user}&course={course}', '{user}');
View
3  course/lib.php
@@ -94,6 +94,9 @@ function make_log_url($module, $url) {
case 'role':
$url = '/'.$url;
break;
+ case 'grade':
+ $url = "/grade/$url";
+ break;
default:
$url = "/mod/$module/$url";
break;
View
25 grade/edit/tree/grade.php
@@ -200,6 +200,18 @@
$data->feedback = $old_grade_grade->feedback;
$data->feedbackformat = $old_grade_grade->feedbackformat;
}
+
+ // Only log a grade override if they actually changed the student grade.
+ if ($data->finalgrade != $old_grade_grade->finalgrade) {
+ $url = '/report/grader/index.php?id=' . $course->id;
+
+ $user = $DB->get_record('user', array('id'=>$data->userid), '*', MUST_EXIST);
+ $fullname = fullname($user);
+
+ $info = "{$grade_item->itemname}: $fullname";
+ add_to_log($course->id, 'grade', 'update', $url, $info);
+ }
+
// update final grade or feedback
// when we set override grade the first time, it happens here
$grade_item->update_final_grade($data->userid, $data->finalgrade, 'editgrade', $data->feedback, $data->feedbackformat);
@@ -213,6 +225,19 @@
$data->overridden = 0; // checkbox unticked
}
$grade_grade->set_overridden($data->overridden);
+
+ if ($data->overridden == 0 && $data->overridden != $old_grade_grade->overridden) {
+ // Log removing an override.
+ // The addition of an override is logged above.
+ // One or the other will happen but never both.
+ $url = '/report/grader/index.php?id=' . $course->id;
+
+ $user = $DB->get_record('user', array('id'=>$data->userid), '*', MUST_EXIST);
+ $fullname = fullname($user);
+
+ $info = "{$grade_item->itemname}: $fullname";
+ add_to_log($course->id, 'grade', 'update', $url, $info);
+ }
}
if (has_capability('moodle/grade:manage', $context) or has_capability('moodle/grade:hide', $context)) {
View
8 grade/report/grader/ajax_callbacks.php
@@ -118,6 +118,14 @@
echo json_encode($json_object);
die();
} else {
+ $url = '/report/grader/index.php?id=' . $course->id;
+
+ $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
+ $fullname = fullname($user);
+
+ $info = "{$grade_item->itemname}: $fullname";
+ add_to_log($course->id, 'grade', 'update', $url, $info);
+
$json_object->gradevalue = $finalvalue;
if ($grade_item->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE)) {
View
6 grade/report/grader/lib.php
@@ -297,6 +297,12 @@ public function process_data($data) {
}
}
+ $url = '/report/grader/index.php?id=' . $this->course->id;
+ $fullname = fullname($this->users[$userid]);
+
+ $info = "{$gradeitem->itemname}: $fullname";
+ add_to_log($this->course->id, 'grade', 'update', $url, $info);
+
$gradeitem->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE);
// We can update feedback without reloading the grade item as it doesn't affect grade calculations
Please sign in to comment.
Something went wrong with that request. Please try again.