From: gustav_delius Date: Sun, 30 May 2004 18:46:42 +0000 (+0000) Subject: Changed participants list for site couse, see http://moodle.org/mod/forum/discuss... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=62b807563275574adbdb1de7a414502ce12e9f6f;p=moodle.git Changed participants list for site couse, see http://moodle.org/mod/forum/discuss.php?d=8455 --- diff --git a/lib/datalib.php b/lib/datalib.php index 27809c4f21..2abcd38102 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1341,20 +1341,23 @@ function get_site_users($sort="u.lastaccess DESC", $select="") { * @param string $sort a SQL snippet for the sorting criteria to use */ function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sort="firstname ASC", - $firstinitial="", $lastinitial="") { + $firstinitial="", $lastinitial="", $page=0, $recordsperpage=99999) { global $CFG; switch ($CFG->dbtype) { case "mysql": + $limit = "LIMIT $page,$recordsperpage"; $fullname = " CONCAT(firstname,\" \",lastname) "; $LIKE = "LIKE"; break; case "postgres7": + $limit = "LIMIT $recordsperpage OFFSET ".($page); $fullname = " firstname||' '||lastname "; $LIKE = "ILIKE"; break; default: + $limit = "LIMIT $recordsperpage,$page"; $fullname = " firstname||\" \"||lastname "; $LIKE = "ILIKE"; } @@ -1387,9 +1390,9 @@ function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sor } if ($get) { - return get_records_select("user", "$select $sort"); + return get_records_select("user", "$select $sort $limit"); } else { - return count_records_select("user", "$select $sort"); + return count_records_select("user", "$select $sort $limit"); } } diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 2f9dde2f30..25deba5001 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -761,6 +761,15 @@ function main_upgrade($oldversion=0) { } } + if ($oldversion < 2004053000) { /// set defaults for site course + $site = get_site(); + set_field('course', 'groupmodeforce', 1, 'id', $site->id); + set_field('course', 'teacher', get_string('administrator'), 'id', $site->id); + set_field('course', 'teachers', get_string('administrators'), 'id', $site->id); + set_field('course', 'student', get_string('user'), 'id', $site->id); + set_field('course', 'students', get_string('users'), 'id', $site->id); + } + return $result; } diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php index 13125a7ee8..87e2acd43c 100644 --- a/lib/db/postgres7.php +++ b/lib/db/postgres7.php @@ -503,6 +503,15 @@ function main_upgrade($oldversion=0) { } } + if ($oldversion < 2004053000) { /// set defaults for site course + $site = get_site(); + set_field('course', 'groupmodeforce', 1, 'id', $site->id); + set_field('course', 'teacher', get_string('administrator'), 'id', $site->id); + set_field('course', 'teachers', get_string('administrators'), 'id', $site->id); + set_field('course', 'student', get_string('user'), 'id', $site->id); + set_field('course', 'students', get_string('users'), 'id', $site->id); + } + return $result; } diff --git a/user/index.php b/user/index.php index feda2bda4e..337ac90e05 100644 --- a/user/index.php +++ b/user/index.php @@ -47,6 +47,8 @@ "$participantslink", "", "", true, " ", navmenu($course)); } + $exceptions = ''; // This will be a list of userids that are shown as teachers and thus + // do not have to be shown as users as well. Only relevant on site course. if ($showteachers) { if ($teachers = get_course_teachers($course->id)) { echo "

$course->teachers

"; @@ -54,32 +56,43 @@ if ($isseparategroups) { if ($teacher->editall or ismember($currentgroup, $teacher->id)) { print_user($teacher, $course); + $exceptions .= "$teacher->id,"; } } else if ($teacher->authority > 0) { // Don't print teachers with no authority print_user($teacher, $course); + $exceptions .= "$teacher->id,"; } } } } - - if ($sort == "lastaccess") { - $dsort = "s.timeaccess"; + $guest = get_guest(); + $exceptions .= $guest->id; + + $site = get_site(); + if ($course->id == $site->id) { // Show all site users (even unconfirmed) + $students = get_users(true, '', true, $exceptions, $sort.' '.$dir, $firstinitial, $lastinitial, $page*$perpage, $perpage); + $totalcount = get_users(false, '', true, '', '', '', '') - 1; // -1 to not count guest user + if ($firstinitial or $lastinitial) { + $matchcount = get_users(false, '', true, '', '', $firstinitial, $lastinitial) - 1; + } else { + $matchcount = $totalcount; + } } else { - $dsort = "u.$sort"; - } - - $students = get_course_students($course->id, $dsort, $dir, $page*$perpage, + if ($sort == "lastaccess") { + $dsort = "s.timeaccess"; + } else { + $dsort = "u.$sort"; + } + $students = get_course_students($course->id, $dsort, $dir, $page*$perpage, $perpage, $firstinitial, $lastinitial, $currentgroup); - - $totalcount = count_course_students($course, "", "", "", $currentgroup); - - if ($firstinitial or $lastinitial) { - $matchcount = count_course_students($course, "", $firstinitial, $lastinitial, $currentgroup); - } else { - $matchcount = $totalcount; + $totalcount = count_course_students($course, "", "", "", $currentgroup); + if ($firstinitial or $lastinitial) { + $matchcount = count_course_students($course, "", $firstinitial, $lastinitial, $currentgroup); + } else { + $matchcount = $totalcount; + } } - echo "

$totalcount $course->students

"; if (($CFG->longtimenosee < 500) and (!$page) and ($sort == "lastaccess")) { @@ -140,7 +153,7 @@ } - if ($matchcount == 0) { + if ($matchcount < 1) { print_heading(get_string("nostudentsfound", "", $course->students)); } if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) { // Print simple listing diff --git a/version.php b/version.php index 807ddf565e..97346c94fc 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ // database to determine whether upgrades should // be performed (see lib/db/*.php) -$version = 2004052800; // The current version is a date (YYYYMMDDXX) +$version = 2004053000; // The current version is a date (YYYYMMDDXX) $release = "1.4 development"; // User-friendly version number