From: martin Date: Sat, 21 Sep 2002 05:42:16 +0000 (+0000) Subject: Better display of users in shortened form, for testing X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6b281f1fecf297fcd60146c27e75f49aeae8c7df;p=moodle.git Better display of users in shortened form, for testing --- 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 "

$course->teachers

"; @@ -44,17 +47,40 @@ } } - if ($students = get_course_students($course->id)) { + if ($students = get_course_students($course->id, "$sort $dir")) { $numstudents = count($students); echo "

$numstudents $course->students

"; - 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 (" ", + "id&sort=u.firstname&dir=$dir\">$string->name", + "id&sort=u.country&dir=$dir\">$string->location", + "id&sort=u.lastaccess&dir=$dir\">$string->lastaccess"); + $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), + " wwwroot/user/view.php?id=$student->id&course=$course->id\">$student->firstname $student->lastname", + "$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 ""; } -function print_user_small($user, $course, $string) { - global $CFG, $USER, $COUNTRIES; - - echo "
"; - echo ""; - echo "
"; - print_user_picture($user->id, $course->id, $user->picture, false); - echo ""; - echo ""; - echo " wwwroot/user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname"; - echo ""; - echo ""; - echo "$user->city, ".$COUNTRIES["$user->country"]." "; - echo ""; - echo ""; - echo ""; - if ($user->lastaccess) { - echo userdate($user->lastaccess); - echo "  (".format_time(time() - $user->lastaccess).")"; - } else { - echo "$string->never"; - } - echo ""; - echo "
"; -} ?>