]> git.mjollnir.org Git - moodle.git/commitdiff
When sending assignment notifications, update "mailed" flag before trying
authormoodler <moodler>
Wed, 9 Jun 2004 07:05:16 +0000 (07:05 +0000)
committermoodler <moodler>
Wed, 9 Jun 2004 07:05:16 +0000 (07:05 +0000)
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

index b57b912e35f61b1f1f139278ceaa5adb48156cbf..097cd1a3e8a5eb589238d8624e0d4656ccf2d630 100644 (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";
-            }
         }
     }