]> git.mjollnir.org Git - moodle.git/commitdiff
Changed participants list for site couse, see http://moodle.org/mod/forum/discuss...
authorgustav_delius <gustav_delius>
Sun, 30 May 2004 18:46:42 +0000 (18:46 +0000)
committergustav_delius <gustav_delius>
Sun, 30 May 2004 18:46:42 +0000 (18:46 +0000)
lib/datalib.php
lib/db/mysql.php
lib/db/postgres7.php
user/index.php
version.php

index 27809c4f21ba5e42dff50c5b532322eab5276045..2abcd3810279c0400eafb0a66cac85ab244f6de5 100644 (file)
@@ -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");
     }
 }
 
index 2f9dde2f3080293938370272baddb67d7748314d..25deba5001fc42daf3f8fd5135b47f3ee88ef537 100644 (file)
@@ -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;
 
 }
index 13125a7ee893f3813aaf4237a080510169d6cf1d..87e2acd43cb088b411b4946f1c44358875aa55d6 100644 (file)
@@ -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;
 
 }
index feda2bda4e385f969bcb9e515551e16dc5dd2803..337ac90e054ad143d54d9013a7d9476cd22e55ec 100644 (file)
@@ -47,6 +47,8 @@
                      "$participantslink", "", "", true, "&nbsp;", 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 "<h2 align=\"center\">$course->teachers</h2>";
                 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 "<h2 align=center>$totalcount $course->students</h2>";
 
     if (($CFG->longtimenosee < 500) and (!$page) and ($sort == "lastaccess")) {
 
     }
 
-    if ($matchcount == 0) {
+    if ($matchcount < 1) {
         print_heading(get_string("nostudentsfound", "", $course->students));
 
     } if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) {    // Print simple listing
index 807ddf565e2d5f25ff264dfaa9b5fecb2dc8a63d..97346c94fcdd7f1ac9cf67fe36b02e27b0ef0f62 100644 (file)
@@ -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