From 0a08581d61932014b2e43232303535baf21f1b5f Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 17 Aug 2003 01:45:26 +0000 Subject: [PATCH] New function get_recent_enrolments() to more efficiently get recent enrolments --- lib/datalib.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/datalib.php b/lib/datalib.php index 4fc6334e9c..2033dab1f1 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -892,6 +892,26 @@ function get_teacher($courseid) { } } +function get_recent_enrolments($courseid, $timestart) { +/// Searches logs to find all enrolments since a certain date +/// and returns the data (used to print recent activity) + + global $CFG; + + return get_records_sql("SELECT u.id, u.firstname, u.lastname + FROM {$CFG->prefix}user u, + {$CFG->prefix}user_students s, + {$CFG->prefix}log l + WHERE l.time > '$timestart' + AND l.course = '$courseid' + AND l.module = 'course' + AND l.action = 'enrol' + AND l.info = u.id + AND u.id = s.userid + GROUP BY l.info + ORDER BY l.time ASC"); +} + function get_course_students($courseid, $sort="u.lastaccess DESC") { /// Returns list of all students in this course /// if courseid = 0 then return ALL students in all courses -- 2.39.5