// Now copy each of these files to the users feedback file area.
foreach ($users as $userid) {
$grade = $this->assignment->get_user_grade($userid, true);
+ $this->assignment->notify_grade_modified($grade);
$this->copy_area_files($fs,
$this->assignment->get_context()->id,
$grade->grade = $record->grade;
$grade->grader = $USER->id;
if ($this->assignment->update_grade($grade)) {
+ $this->assignment->notify_grade_modified($grade);
$this->assignment->add_to_log('grade submission', $this->assignment->format_grade_for_log($grade));
$updatecount += 1;
}
if ($newvalue != $oldvalue) {
$updatecount += 1;
$grade = $this->assignment->get_user_grade($record->user->id, true);
+ $this->assignment->notify_grade_modified($grade);
if ($plugin->set_editor_text($field, $newvalue, $grade->id)) {
$logdesc = get_string('feedbackupdate', 'assignfeedback_offline',
array('field'=>$description,
return true;
}
+ /**
+ * 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
*
$grade->grade = -1;
$grade->grader = $USER->id;
$grade->extensionduedate = 0;
+
+ // 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;
}
$this->update_grade($grade);
+ $this->notify_grade_modified($grade);
// save outcomes
if ($CFG->enableoutcomes) {
}
}
$this->update_grade($grade);
+ $this->notify_grade_modified($grade);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$this->add_to_log('grade submission', $this->format_grade_for_log($grade));