2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
// Lists all the users within a given course
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../config.php");
|
|
|
|
require_once("lib.php");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
require_variable($id); //course
|
2002-09-22 14:06:38 +00:00
|
|
|
optional_variable($sort, "lastaccess"); //how to sort students
|
2003-09-18 04:46:34 +00:00
|
|
|
optional_variable($dir,"desc"); //how to sort students
|
|
|
|
optional_variable($page, "0"); // which page to show
|
2003-11-04 12:09:52 +00:00
|
|
|
optional_variable($lastinitial, ""); // only show students with this last initial
|
|
|
|
optional_variable($firstinitial, ""); // only show students with this first initial
|
2003-09-18 04:46:34 +00:00
|
|
|
optional_variable($perpage, "20"); // how many per page
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-08-10 08:01:14 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course ID is incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course->id);
|
|
|
|
|
2002-05-31 09:15:36 +00:00
|
|
|
add_to_log($course->id, "user", "view all", "index.php?id=$course->id", "");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-06 09:21:14 +00:00
|
|
|
$string->email = get_string("email");
|
|
|
|
$string->location = get_string("location");
|
|
|
|
$string->lastaccess = get_string("lastaccess");
|
|
|
|
$string->activity = get_string("activity");
|
|
|
|
$string->unenrol = get_string("unenrol");
|
|
|
|
$string->loginas = get_string("loginas");
|
|
|
|
$string->fullprofile = get_string("fullprofile");
|
2002-09-08 03:34:12 +00:00
|
|
|
$string->role = get_string("role");
|
|
|
|
$string->never = get_string("never");
|
2002-09-21 05:42:16 +00:00
|
|
|
$string->name = get_string("name");
|
2002-10-03 04:04:59 +00:00
|
|
|
$string->day = get_string("day");
|
|
|
|
$string->days = get_string("days");
|
|
|
|
$string->hour = get_string("hour");
|
|
|
|
$string->hours = get_string("hours");
|
|
|
|
$string->min = get_string("min");
|
|
|
|
$string->mins = get_string("mins");
|
|
|
|
$string->sec = get_string("sec");
|
|
|
|
$string->secs = get_string("secs");
|
2003-11-04 12:09:52 +00:00
|
|
|
$string->all = get_string("all");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-09-26 08:04:48 +00:00
|
|
|
$countries = get_list_of_countries();
|
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
$loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
$showteachers = ($page == 0 and $sort == "lastaccess" and $dir == "desc");
|
|
|
|
|
|
|
|
if ($showteachers) {
|
|
|
|
$participantslink = get_string("participants");
|
2002-09-22 14:06:38 +00:00
|
|
|
} else {
|
2003-09-18 04:46:34 +00:00
|
|
|
$participantslink = "<a href=\"index.php?id=$course->id\">".get_string("participants")."</a>";
|
2002-09-22 14:06:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
if ($course->category) {
|
|
|
|
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
|
|
|
"<A HREF=../course/view.php?id=$course->id>$course->shortname</A> -> ".
|
|
|
|
"$participantslink", "", "", true, " ", $loggedinas);
|
2003-04-28 04:32:55 +00:00
|
|
|
} else {
|
2003-09-18 04:46:34 +00:00
|
|
|
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
|
|
|
"$participantslink", "", "", true, " ", $loggedinas);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($showteachers) {
|
|
|
|
if ( $teachers = get_course_teachers($course->id)) {
|
|
|
|
echo "<h2 align=center>$course->teachers</h2>";
|
|
|
|
foreach ($teachers as $teacher) {
|
|
|
|
if ($teacher->authority > 0) { // Don't print teachers with no authority
|
2003-09-26 08:04:48 +00:00
|
|
|
print_user($teacher, $course, $string, $countries);
|
2003-09-18 04:46:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-28 04:32:55 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 14:24:44 +00:00
|
|
|
if ($sort == "lastaccess") {
|
2003-10-27 12:38:00 +00:00
|
|
|
$dsort = "s.timeaccess";
|
|
|
|
} else {
|
|
|
|
$dsort = "u.$sort";
|
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
$students = get_course_students($course->id, $dsort, $dir, $page*$perpage,
|
|
|
|
$perpage, $firstinitial, $lastinitial);
|
|
|
|
|
|
|
|
$totalcount = $matchcount = count_records("user_students", "course", $course->id);
|
2003-04-28 16:13:46 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
echo "<h2 align=center>$totalcount $course->students</h2>";
|
2003-04-29 12:51:21 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
if (($CFG->longtimenosee < 500) and (!$page) and ($sort == "lastaccess")) {
|
2003-05-16 06:27:23 +00:00
|
|
|
echo "<center><p><font size=1>(";
|
|
|
|
print_string("unusedaccounts","",$CFG->longtimenosee);
|
|
|
|
echo ")</font></p></center>";
|
|
|
|
}
|
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
/// Print paging bars if necessary
|
2003-09-18 04:46:34 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
if ($totalcount > $perpage) {
|
|
|
|
$alphabet = explode(',', get_string('alphabet'));
|
|
|
|
|
|
|
|
/// Bar of first initials
|
|
|
|
|
|
|
|
echo "<center><p align=\"center\">";
|
|
|
|
echo get_string("firstname")." : ";
|
|
|
|
if ($firstinitial) {
|
|
|
|
echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
|
|
|
|
"perpage=$perpage&lastinitial=$lastinitial\">$string->all</a> ";
|
|
|
|
} else {
|
|
|
|
echo " <b>$string->all</b> ";
|
|
|
|
}
|
|
|
|
foreach ($alphabet as $letter) {
|
|
|
|
if ($letter == $firstinitial) {
|
|
|
|
echo " <b>$letter</b> ";
|
|
|
|
} else {
|
|
|
|
echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
|
|
|
|
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
|
2003-09-20 05:19:02 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
}
|
2003-11-04 12:09:52 +00:00
|
|
|
echo "<br />";
|
2003-09-18 04:46:34 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
/// Bar of last initials
|
2003-09-18 04:46:34 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
echo get_string("lastname")." : ";
|
|
|
|
if ($lastinitial) {
|
|
|
|
echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
|
|
|
|
"perpage=$perpage&firstinitial=$firstinitial\">$string->all</a> ";
|
|
|
|
} else {
|
|
|
|
echo " <b>$string->all</b> ";
|
|
|
|
}
|
|
|
|
foreach ($alphabet as $letter) {
|
|
|
|
if ($letter == $lastinitial) {
|
|
|
|
echo " <b>$letter</b> ";
|
|
|
|
} else {
|
|
|
|
echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
|
|
|
|
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</p>";
|
|
|
|
echo "</center>";
|
|
|
|
|
|
|
|
$matchcount = count_course_students($course, "", $firstinitial, $lastinitial);
|
|
|
|
|
|
|
|
print_paging_bar($matchcount, $page, $perpage,
|
|
|
|
"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($matchcount == 0) {
|
|
|
|
print_heading(get_string("nostudentsfound", "", $course->students));
|
|
|
|
|
|
|
|
} if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) { // Print simple listing
|
|
|
|
foreach ($students as $student) {
|
|
|
|
print_user($student, $course, $string, $countries);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ($matchcount > 0) {
|
2002-11-12 03:02:51 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
// Print one big table with abbreviated info
|
|
|
|
$columns = array("firstname", "lastname", "city", "country", "lastaccess");
|
2002-09-22 14:06:38 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
foreach ($columns as $column) {
|
|
|
|
$colname[$column] = get_string($column);
|
|
|
|
if ($sort != $column) {
|
|
|
|
$columnicon = "";
|
2002-09-22 14:06:38 +00:00
|
|
|
if ($column == "lastaccess") {
|
2003-09-18 04:46:34 +00:00
|
|
|
$columndir = "desc";
|
2002-09-22 14:06:38 +00:00
|
|
|
} else {
|
2003-09-18 04:46:34 +00:00
|
|
|
$columndir = "asc";
|
2002-09-22 14:06:38 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
} else {
|
|
|
|
$columndir = $dir == "asc" ? "desc":"asc";
|
|
|
|
if ($column == "lastaccess") {
|
|
|
|
$columnicon = $dir == "asc" ? "up":"down";
|
2002-09-22 14:06:38 +00:00
|
|
|
} else {
|
2003-09-18 04:46:34 +00:00
|
|
|
$columnicon = $dir == "asc" ? "down":"up";
|
2002-09-22 14:06:38 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" />";
|
2002-09-21 06:27:00 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
$$column = "<a href=\"index.php?id=$course->id&sort=$column&dir=$columndir\">".$colname["$column"]."</a>$columnicon";
|
|
|
|
}
|
2002-09-22 14:06:38 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
foreach ($students as $key => $student) {
|
2003-09-26 08:04:48 +00:00
|
|
|
$students[$key]->country = $countries[$student->country];
|
2003-09-18 04:46:34 +00:00
|
|
|
}
|
|
|
|
if ($sort == "country") { // Need to re-sort by full country name, not code
|
|
|
|
foreach ($students as $student) {
|
|
|
|
$sstudents[$student->id] = $student->country;
|
2002-09-22 16:16:13 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
asort($sstudents);
|
|
|
|
foreach ($sstudents as $key => $value) {
|
|
|
|
$nstudents[] = $students[$key];
|
2002-09-22 16:16:13 +00:00
|
|
|
}
|
2003-09-18 04:46:34 +00:00
|
|
|
$students = $nstudents;
|
|
|
|
}
|
2002-09-22 16:16:13 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
$table->head = array (" ", "$firstname / $lastname", $city, $country, $lastaccess);
|
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("10", "*", "*", "*", "*");
|
|
|
|
$table->size = array ("10", "*", "*", "*", "*");
|
2003-10-21 06:40:39 +00:00
|
|
|
$table->cellpadding = 4;
|
2003-09-18 04:46:34 +00:00
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
|
|
|
foreach ($students as $student) {
|
|
|
|
|
|
|
|
if ($student->lastaccess) {
|
|
|
|
$lastaccess = format_time(time() - $student->lastaccess, $string);
|
|
|
|
} else {
|
|
|
|
$lastaccess = $string->never;
|
|
|
|
}
|
2003-04-28 04:32:55 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
if ($showall and $numstudents > USER_LARGE_CLASS) { // Don't show pictures
|
|
|
|
$picture = "";
|
|
|
|
} else {
|
|
|
|
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
|
|
|
}
|
2002-09-21 05:42:16 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
$table->data[] = array ($picture,
|
|
|
|
"<b><a href=\"$CFG->wwwroot/user/view.php?id=$student->id&course=$course->id\">$student->firstname $student->lastname</a></b>",
|
|
|
|
"<font size=2>$student->city</font>",
|
|
|
|
"<font size=2>$student->country</font>",
|
|
|
|
"<font size=2>$lastaccess</font>");
|
|
|
|
}
|
|
|
|
print_table($table);
|
2002-09-21 06:39:28 +00:00
|
|
|
|
2003-11-04 12:09:52 +00:00
|
|
|
print_paging_bar($matchcount, $page, $perpage,
|
2003-11-12 07:40:09 +00:00
|
|
|
"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
2003-04-14 02:48:40 +00:00
|
|
|
|
2003-09-18 04:46:34 +00:00
|
|
|
if ($perpage != 99999) {
|
|
|
|
echo "<center><p>";
|
|
|
|
echo "<a href=\"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=99999\">".get_string("showall", "", $totalcount)."</a>";
|
|
|
|
echo "</p></center>";
|
2002-11-22 17:28:55 +00:00
|
|
|
}
|
2003-11-04 12:09:52 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|