When sending assignment notifications, update "mailed" flag before trying

to mail them.  This helps prevent multiple mail problems if cron or
smtp has major problems.


http://moodle.org/mod/forum/discuss.php?d=8821
This commit is contained in:
moodler 2004-06-09 07:05:16 +00:00
parent 3ebd4a1621
commit a56d79cdc8

View File

@ -201,6 +201,14 @@ function assignment_cron () {
$cutofftime = time() - $CFG->maxeditingtime;
if ($submissions = assignment_get_unmailed_submissions($cutofftime)) {
foreach ($submissions as $key => $submission) {
if (! set_field("assignment_submissions", "mailed", "1", "id", "$submission->id")) {
echo "Could not update the mailed field for id $submission->id. Not mailed.\n";
unset($submissions[$key]);
}
}
$timenow = time();
foreach ($submissions as $submission) {
@ -267,9 +275,6 @@ function assignment_cron () {
if (! email_to_user($user, $teacher, $postsubject, $posttext, $posthtml)) {
echo "Error: assignment cron: Could not send out mail for id $submission->id to user $user->id ($user->email)\n";
}
if (! set_field("assignment_submissions", "mailed", "1", "id", "$submission->id")) {
echo "Could not update the mailed field for id $submission->id\n";
}
}
}