Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-36667-23' of git://github.com/damyon/moodle into MO…

…ODLE_23_STABLE
  • Loading branch information...
commit 523dafe82452ffd7637b52de7298f487a258db25 2 parents fc77cb3 + 3f1b280
@danpoltawski danpoltawski authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 mod/assign/locallib.php
View
23 mod/assign/locallib.php
@@ -1347,6 +1347,23 @@ static function cron() {
}
/**
+ * Mark in the database that this grade record should have an update notification sent by cron.
+ *
+ * @param stdClass $grade a grade record keyed on id
+ * @return bool true for success
+ */
+ public function notify_grade_modified($grade) {
+ global $DB;
+
+ $grade->timemodified = time();
+ if ($grade->mailed != 1) {
+ $grade->mailed = 0;
+ }
+
+ return $DB->update_record('assign_grades', $grade);
+ }
+
+ /**
* Update a grade in the grade table for the assignment and in the gradebook
*
* @param stdClass $grade a grade record keyed on id
@@ -1691,6 +1708,10 @@ private function get_user_grade($userid, $create) {
$grade->locked = 0;
$grade->grade = -1;
$grade->grader = $USER->id;
+
+ // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet.
+ // This is because students only want to be notified about certain types of update (grades and feedback).
+ $grade->mailed = 2;
$gid = $DB->insert_record('assign_grades', $grade);
$grade->id = $gid;
return $grade;
@@ -2761,6 +2782,7 @@ private function process_save_quick_grades() {
}
$this->update_grade($grade);
+ $this->notify_grade_modified($grade);
// save outcomes
if ($CFG->enableoutcomes) {
@@ -3406,6 +3428,7 @@ private function process_save_grade(&$mform) {
$grade->mailed = 0;
$this->update_grade($grade);
+ $this->notify_grade_modified($grade);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
Please sign in to comment.
Something went wrong with that request. Please try again.