Better display of users in shortened form, for testing

This commit is contained in:
martin
2002-09-21 05:42:16 +00:00
parent 7a702c34ea
commit 6b281f1fec
2 changed files with 31 additions and 30 deletions
+31 -5
View File
@@ -7,6 +7,8 @@
require("lib.php");
require_variable($id); //course
optional_variable($sort, "u.lastaccess"); //how to sort students
optional_variable($dir,"ASC"); //how to sort students
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
@@ -34,6 +36,7 @@
$string->fullprofile = get_string("fullprofile");
$string->role = get_string("role");
$string->never = get_string("never");
$string->name = get_string("name");
if ( $teachers = get_course_teachers($course->id)) {
echo "<H2 align=center>$course->teachers</H2>";
@@ -44,17 +47,40 @@
}
}
if ($students = get_course_students($course->id)) {
if ($students = get_course_students($course->id, "$sort $dir")) {
$numstudents = count($students);
echo "<H2 align=center>$numstudents $course->students</H2>";
if ($numstudents < 40) {
if ($numstudents < 30) {
foreach ($students as $student) {
print_user($student, $course, $string);
}
} else {
foreach ($students as $student) {
print_user_small($student, $course, $string);
} else { // Print one big table with abbreviated info
if ($dir == "ASC") {
$dir = "DESC";
} else {
$dir = "ASC";
}
$table->head = array ("&nbsp;",
"<A HREF=\"index.php?id=$course->id&sort=u.firstname&dir=$dir\">$string->name</A>",
"<A HREF=\"index.php?id=$course->id&sort=u.country&dir=$dir\">$string->location</A>",
"<A HREF=\"index.php?id=$course->id&sort=u.lastaccess&dir=$dir\">$string->lastaccess</A>");
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT");
$table->size = array ("35", "*", "*", "*");
foreach ($students as $student) {
if ($student->lastaccess) {
$lastaccess = userdate($student->lastaccess);
$lastaccess .= "&nbsp (".format_time(time() - $student->lastaccess).")";
} else {
$lastaccess = $string->never;
}
$table->data[] = array (print_user_picture($student->id, $course->id, $student->picture, false, true),
"<B>&nbsp;<A HREF=\"$CFG->wwwroot/user/view.php?id=$student->id&course=$course->id\">$student->firstname $student->lastname</A></B>",
"$student->city, ".$COUNTRIES["$student->country"],
"$lastaccess");
}
print_table($table, 2, 0);
}
}
-25
View File
@@ -88,29 +88,4 @@ function print_user($user, $course, $string) {
echo "</TD></TR></TABLE></TD></TR></TABLE>";
}
function print_user_small($user, $course, $string) {
global $CFG, $USER, $COUNTRIES;
echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
echo "<TD WIDTH=35 BGCOLOR=#FFFFFF>";
print_user_picture($user->id, $course->id, $user->picture, false);
echo "</A>";
echo "</TD><TD BGCOLOR=#FFFFFF>";
echo "<FONT SIZE=2><B>&nbsp;<A HREF=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A></B></FONT>";
echo "</TD><TD BGCOLOR=#FFFFFF NOWRAP ALIGN=right>";
echo "<FONT SIZE=1>";
echo "<I>$user->city, ".$COUNTRIES["$user->country"]."</I>&nbsp;";
echo "</FONT>";
echo "</TD><TD BGCOLOR=#FFFFFF NOWRAP ALIGN=right>";
echo "<FONT SIZE=1>";
if ($user->lastaccess) {
echo userdate($user->lastaccess);
echo "&nbsp (".format_time(time() - $user->lastaccess).")";
} else {
echo "$string->never";
}
echo "</FONT>";
echo "</TD></TR></TABLE></TD></TR></TABLE>";
}
?>