From 210751f6b8f678dd4a67ecdef0e2c70c2cf92c12 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Mon, 28 Jun 2010 12:19:23 +0000 Subject: [PATCH] fixed SQL error when user repeatedly enrolled/unenrolled during a short period --- lib/deprecatedlib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 4f297848a8d..e4f74626d6f 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -182,7 +182,7 @@ function get_recent_enrolments($courseid, $timestart) { $context = get_context_instance(CONTEXT_COURSE, $courseid); - $sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, l.time + $sql = "SELECT u.id, u.firstname, u.lastname, MAX(l.time) FROM {user} u, {role_assignments} ra, {log} l WHERE l.time > ? AND l.course = ? @@ -191,7 +191,8 @@ function get_recent_enrolments($courseid, $timestart) { AND ".$DB->sql_cast_char2int('l.info')." = u.id AND u.id = ra.userid AND ra.contextid ".get_related_contexts_string($context)." - ORDER BY l.time ASC"; + GROUP BY u.id, u.firstname, u.lastname + ORDER BY MAX(l.time) ASC"; $params = array($timestart, $courseid); return $DB->get_records_sql($sql, $params); }