}
/**
-* Returns list of all students in this course
+* Returns array of userinfo of all students in this course
+* or on this site if courseid is id of site
*
* @param type description
*/
global $CFG;
+ $site = get_site();
+ if ($courseid == $site->id) {
+ $sort = str_replace('s.timeaccess', '', $sort); // site users can't be sorted by timeaccess
+ $sort = str_replace('u.', '', $sort); // the get_user function doesn't use the u. prefix to fields
+ if ($sort) {
+ $sort = "$sort $dir";
+ }
+ return get_users(true, $search, true, '', $sort, $firstinitial, $lastinitial, $page, $recordsperpage);
+ }
+
switch ($CFG->dbtype) {
case "mysql":
$fullname = " CONCAT(firstname,\" \",lastname) ";
}
/**
-* Counts the students in a given course, or a subset of them
+* Counts the students in a given course (or site), or a subset of them
*
* @param type description
*/
global $CFG;
+ if (!$course->category) {
+ return get_users(false, $search, true, '', '', $firstinitial, $lastinitial);
+ }
+
switch ($CFG->dbtype) {
case "mysql":
$fullname = " CONCAT(firstname,\" \",lastname) ";
/**
-* Returns list of all teachers in this course
+* Returns list of all teachers in this course
+* (also works for site)
*
* @param type description
*/
$site = get_site();
if ($courseid == $site->id) {
- return get_site_users();
+ return get_users(true, '', true, '', $sort);
}
/// Using this method because the single SQL just would not always work!
function isstudent($courseid, $userid=0) {
/// Is the user a student in this course?
+/// If course is site, is the user a confirmed user on the site?
global $USER;
+ $site = get_site();
+ if ($courseid == $site->id) {
+ if (!$userid) {
+ $userid = $USER->id;
+ }
+ if (isguest($userid)) {
+ return false;
+ }
+ return record_exists('user', 'id', $userid, 'confirmed', 1, 'deleted', 0);
+ }
+
if (!$userid) {
return !empty($USER->student[$courseid]);
}