Skip to content

Commit

Permalink
When sending assignment notifications, update "mailed" flag before tr…
Browse files Browse the repository at this point in the history
…ying

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
moodler committed Jun 9, 2004
1 parent 3ebd4a1 commit a56d79c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
@@ -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";
}
}
}

0 comments on commit a56d79c

Please sign in to comment.