Permalink
Browse files

MDL-36712: Assignment - Do not always send feedback available emails …

…when grade is created

The entry in the assign_grades table contains grades feedback and other settings such as locked.
Only send the student an email about new feedback if it is actually grades or feedback that
has been added. This is done by using another state for the mailed flag (2) which means "unset".

Conflicts:

	mod/assign/feedback/file/importziplib.php
	mod/assign/feedback/file/locallib.php
	mod/assign/feedback/offline/locallib.php
	mod/assign/locallib.php
  • Loading branch information...
1 parent 10ad21d commit 3f1b2800ae47ac50fb8fe67176efb6861e72a806 @damyon damyon committed Nov 21, 2012
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);

0 comments on commit 3f1b280

Please sign in to comment.