New function get_recent_enrolments() to more efficiently get recent enrolments
authormoodler <moodler>
Sun, 17 Aug 2003 01:45:26 +0000 (01:45 +0000)
committermoodler <moodler>
Sun, 17 Aug 2003 01:45:26 +0000 (01:45 +0000)
lib/datalib.php

index 4fc6334e9c672d9b4c87654997b7be95e950f9cc..2033dab1f1b122c8f54abcf997958ca8c707bed2 100644 (file)
@@ -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