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/countries.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-04-14 02:42:40 +00:00
|
|
|
optional_variable($dir,"DESC"); //how to sort students
|
2003-04-14 05:44:47 +00:00
|
|
|
optional_variable($showall,""); //show all of the students?
|
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
|
|
|
|
|
|
|
if ($course->category) {
|
2002-07-04 07:52:06 +00:00
|
|
|
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
|
|
|
"<A HREF=../course/view.php?id=$course->id>$course->shortname</A> -> ".
|
|
|
|
get_string("participants"), "");
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
2002-07-04 07:52:06 +00:00
|
|
|
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
|
|
|
get_string("participants"), "");
|
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");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-07-29 06:53:09 +00:00
|
|
|
if ( $teachers = get_course_teachers($course->id)) {
|
2002-09-08 03:24:38 +00:00
|
|
|
echo "<H2 align=center>$course->teachers</H2>";
|
2001-11-22 06:23:56 +00:00
|
|
|
foreach ($teachers as $teacher) {
|
2002-09-01 14:30:39 +00:00
|
|
|
if ($teacher->authority > 0) { // Don't print teachers with no authority
|
|
|
|
print_user($teacher, $course, $string);
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-22 14:06:38 +00:00
|
|
|
if ($sort == "name") {
|
|
|
|
$dsort = "u.firstname";
|
|
|
|
} else {
|
|
|
|
$dsort = "u.$sort";
|
|
|
|
}
|
|
|
|
|
2003-04-28 04:32:55 +00:00
|
|
|
if (!$showall) {
|
|
|
|
$limit = "LIMIT ".USER_LARGE_CLASS;
|
|
|
|
} else {
|
|
|
|
$limit = "";
|
|
|
|
}
|
|
|
|
|
2003-04-28 16:13:46 +00:00
|
|
|
$numstudentsall = count_records("user_students", "course", $course->id);
|
|
|
|
|
2003-04-29 12:51:21 +00:00
|
|
|
echo "<h2 align=center>$numstudentsall $course->students</h2>";
|
|
|
|
|
2003-04-28 04:32:55 +00:00
|
|
|
if ($students = get_course_students($course->id, "$dsort $dir $limit")) {
|
2002-09-20 15:40:20 +00:00
|
|
|
$numstudents = count($students);
|
2003-04-28 04:32:55 +00:00
|
|
|
if ($numstudents < USER_SMALL_CLASS) {
|
2002-09-20 15:40:20 +00:00
|
|
|
foreach ($students as $student) {
|
|
|
|
print_user($student, $course, $string);
|
|
|
|
}
|
2002-11-12 03:02:51 +00:00
|
|
|
|
2002-09-21 05:42:16 +00:00
|
|
|
} else { // Print one big table with abbreviated info
|
2002-09-22 14:06:38 +00:00
|
|
|
$columns = array("name", "city", "country", "lastaccess");
|
|
|
|
|
|
|
|
foreach ($columns as $column) {
|
|
|
|
$colname[$column] = get_string($column);
|
|
|
|
$columnsort = $column;
|
|
|
|
if ($column == "lastaccess") {
|
|
|
|
$columndir = "DESC";
|
|
|
|
} else {
|
|
|
|
$columndir = "ASC";
|
|
|
|
}
|
|
|
|
if ($columnsort == $sort) {
|
|
|
|
$$column = $colname["$column"];
|
|
|
|
} else {
|
2003-04-29 12:51:21 +00:00
|
|
|
$$column = "<a href=\"index.php?id=$course->id&sort=$columnsort&dir=$columndir&showall=$showall\">".$colname["$column"]."</a>";
|
2002-09-22 14:06:38 +00:00
|
|
|
}
|
2002-09-21 06:27:00 +00:00
|
|
|
}
|
2002-09-22 14:06:38 +00:00
|
|
|
|
2002-09-22 16:16:13 +00:00
|
|
|
foreach ($students as $key => $student) {
|
|
|
|
$students[$key]->country = $COUNTRIES[$student->country];
|
|
|
|
}
|
|
|
|
if ($sort == "country") { // Need to re-sort by full country name, not code
|
|
|
|
foreach ($students as $student) {
|
|
|
|
$sstudents[$student->id] = $student->country;
|
|
|
|
}
|
|
|
|
asort($sstudents);
|
|
|
|
foreach ($sstudents as $key => $value) {
|
|
|
|
$nstudents[] = $students[$key];
|
|
|
|
}
|
|
|
|
$students = $nstudents;
|
|
|
|
}
|
|
|
|
|
2002-09-22 14:06:38 +00:00
|
|
|
$table->head = array (" ", $name, $city, $country, $lastaccess);
|
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("10", "*", "*", "*", "*");
|
2002-09-22 14:11:45 +00:00
|
|
|
$table->size = array ("10", "*", "*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
2002-09-21 05:42:16 +00:00
|
|
|
|
2002-09-20 15:40:20 +00:00
|
|
|
foreach ($students as $student) {
|
2003-04-28 04:32:55 +00:00
|
|
|
|
2002-09-21 05:42:16 +00:00
|
|
|
if ($student->lastaccess) {
|
2002-10-03 04:04:59 +00:00
|
|
|
$lastaccess = format_time(time() - $student->lastaccess, $string);
|
2002-09-21 05:42:16 +00:00
|
|
|
} else {
|
|
|
|
$lastaccess = $string->never;
|
|
|
|
}
|
|
|
|
|
2003-04-28 04:32:55 +00:00
|
|
|
if ($showall and $numstudents > USER_LARGE_CLASS) { // Don't show pictures
|
2002-09-21 06:39:28 +00:00
|
|
|
$picture = "";
|
|
|
|
} else {
|
|
|
|
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->data[] = array ($picture,
|
2003-04-29 12:51:21 +00:00
|
|
|
"<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>");
|
2002-09-20 15:40:20 +00:00
|
|
|
}
|
2002-09-22 14:11:45 +00:00
|
|
|
print_table($table);
|
2002-11-22 17:28:55 +00:00
|
|
|
|
2003-04-28 16:13:46 +00:00
|
|
|
if ($numstudents < $numstudentsall and !$showall) {
|
|
|
|
$moreinfo->count = $numstudents;
|
2003-04-14 02:52:11 +00:00
|
|
|
$moreinfo->things = strtolower($course->students);
|
|
|
|
echo "<center><p>".get_string("displayingfirst", "", $moreinfo);
|
2003-04-28 16:13:46 +00:00
|
|
|
echo " (<a href=\"index.php?id=$course->id&sort=$sort&dir=$dir&showall=1\">".get_string("showall", "", $numstudentsall)."</a>)";
|
2003-04-14 02:48:40 +00:00
|
|
|
echo "</p></center>";
|
|
|
|
}
|
|
|
|
|
2002-11-22 17:28:55 +00:00
|
|
|
}
|
|
|
|
if ($CFG->longtimenosee < 500) {
|
2003-04-29 12:51:21 +00:00
|
|
|
echo "<center><p><font size=1>(";
|
2002-11-22 17:28:55 +00:00
|
|
|
print_string("unusedaccounts","",$CFG->longtimenosee);
|
2003-04-29 12:51:21 +00:00
|
|
|
echo ")</font></p></center>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2002-06-05 05:54:47 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|