diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 167406fc416d2..be0db0495544f 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1560,8 +1560,8 @@ public static function cron() { $timenow = time(); // Collect all submissions from the past 24 hours that require mailing. - $sql = 'SELECT a.course, a.name, a.blindmarking, a.revealidentities, - g.*, g.id as gradeid, g.timemodified as lastmodified + $sql = 'SELECT g.id as gradeid, a.course, a.name, a.blindmarking, a.revealidentities, + g.*, g.timemodified as lastmodified FROM {assign} a JOIN {assign_grades} g ON g.assignment = a.id LEFT JOIN {assign_user_flags} uf ON uf.assignment = a.id AND uf.userid = g.userid