From a56d79cdc82e507644627b304fd2a7359f85b3d5 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 9 Jun 2004 07:05:16 +0000 Subject: [PATCH] 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 --- mod/assignment/lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index b57b912e35..097cd1a3e8 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -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"; - } } } -- 2.39.5