From 6b281f1fecf297fcd60146c27e75f49aeae8c7df Mon Sep 17 00:00:00 2001 From: martin <martin> Date: Sat, 21 Sep 2002 05:42:16 +0000 Subject: [PATCH] Better display of users in shortened form, for testing --- user/index.php | 34 ++++++++++++++++++++++++++++++---- user/lib.php | 25 ------------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/user/index.php b/user/index.php index cac622d825..4bd1f610d0 100644 --- a/user/index.php +++ b/user/index.php @@ -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 { + } else { // Print one big table with abbreviated info + if ($dir == "ASC") { + $dir = "DESC"; + } else { + $dir = "ASC"; + } + $table->head = array (" ", + "<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) { - print_user_small($student, $course, $string); + if ($student->lastaccess) { + $lastaccess = userdate($student->lastaccess); + $lastaccess .= "  (".format_time(time() - $student->lastaccess).")"; + } else { + $lastaccess = $string->never; + } + + $table->data[] = array (print_user_picture($student->id, $course->id, $student->picture, false, true), + "<B> <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); } } diff --git a/user/lib.php b/user/lib.php index d0b941efd3..fa085030e7 100644 --- a/user/lib.php +++ b/user/lib.php @@ -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> <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> "; - echo "</FONT>"; - echo "</TD><TD BGCOLOR=#FFFFFF NOWRAP ALIGN=right>"; - echo "<FONT SIZE=1>"; - if ($user->lastaccess) { - echo userdate($user->lastaccess); - echo "  (".format_time(time() - $user->lastaccess).")"; - } else { - echo "$string->never"; - } - echo "</FONT>"; - echo "</TD></TR></TABLE></TD></TR></TABLE>"; -} ?> -- 2.39.5