From bb09dd2ff4eb0ace5161e3b73cbb87b702cba725 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 28 Jun 2017 10:41:41 +1200 Subject: [PATCH] Improve messages in cron, check end of session correctly. --- classes/task/notify.php | 3 +++ locallib.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/task/notify.php b/classes/task/notify.php index a5a8a3c..115779b 100644 --- a/classes/task/notify.php +++ b/classes/task/notify.php @@ -48,6 +48,9 @@ class notify extends \core\task\scheduled_task { if (empty($lastrun)) { $lastrun = 0; } + if (!empty($lastrun)) { + mtrace("Get warnings to send for sessions that have ended since: ".userdate($lastrun)); + } $orderby = 'ORDER BY cm.id, atl.studentid, n.warningpercent ASC'; $records = attendance_get_users_to_notify(array(), $orderby, $lastrun, true); diff --git a/locallib.php b/locallib.php index 0814bba..ab27a19 100644 --- a/locallib.php +++ b/locallib.php @@ -763,7 +763,7 @@ function attendance_get_users_to_notify($courseids = array(), $orderby = '', $si GROUP BY attendanceid, setnumber) stm ON (stm.setnumber = ats.statusset AND stm.attendanceid = ats.attendanceid) {$joingroup} - WHERE ats.sessdate >= {$sincetime} {$where} + WHERE (ats.sessdate + ats.duration) >= {$sincetime} {$where} AND ats.lasttaken != 0 GROUP BY uniqueid, a.id, a.name, a.course, c.fullname, atl.studentid, n.id, n.warningpercent, n.emailsubject, n.emailcontent, n.emailcontentformat, n.warnafter,