Skip to content

Commit

Permalink
MDL-52904 completion: reference context in cron query
Browse files Browse the repository at this point in the history
Co-authored-by: Barbara Lawrence <blawrence@harlow-college.ac.uk>
  • Loading branch information
2 people authored and junpataleta committed May 4, 2020
1 parent 2ddc2e8 commit 8a29ee1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/classes/task/completion_daily_task.php
Expand Up @@ -71,7 +71,8 @@ public function execute() {
INNER JOIN {user_enrolments} ue ON ue.userid = u.id
INNER JOIN {enrol} e ON e.id = ue.enrolid
INNER JOIN {course} c ON c.id = e.courseid
INNER JOIN {role_assignments} ra ON ra.userid = u.id
INNER JOIN {context} con ON con.contextlevel = ? AND con.instanceid = c.id
INNER JOIN {role_assignments} ra ON ra.userid = u.id AND ra.contextid = con.id
LEFT JOIN {course_completions} crc ON crc.course = c.id AND crc.userid = u.id
WHERE c.enablecompletion = 1
AND crc.timeenrolled IS NULL
Expand All @@ -83,7 +84,7 @@ public function execute() {
$sqlroles
ORDER BY course, userid";
$now = time();
$rs = $DB->get_recordset_sql($sql, [$now, $now, $now, $now]);
$rs = $DB->get_recordset_sql($sql, [CONTEXT_COURSE, $now, $now]);

// Check if result is empty.
if (!$rs->valid()) {
Expand Down

0 comments on commit 8a29ee1

Please sign in to comment.