f9903ed0 |
1 | <?PHP // $Id$ |
2 | |
3 | // Lists all the users within a given course |
4 | |
5 | require("../config.php"); |
bda8d43a |
6 | require("../lib/countries.php"); |
f9903ed0 |
7 | require("lib.php"); |
8 | |
9 | require_variable($id); //course |
6b281f1f |
10 | optional_variable($sort, "u.lastaccess"); //how to sort students |
e6b9ee04 |
11 | optional_variable($dir,"DESC"); //how to sort students |
f9903ed0 |
12 | |
13 | if (! $course = get_record("course", "id", $id)) { |
14 | error("Course ID is incorrect"); |
15 | } |
16 | |
17 | require_login($course->id); |
18 | |
da3a08d7 |
19 | add_to_log($course->id, "user", "view all", "index.php?id=$course->id", ""); |
f9903ed0 |
20 | |
21 | if ($course->category) { |
fa0626c6 |
22 | print_header("$course->shortname: ".get_string("participants"), "$course->fullname", |
23 | "<A HREF=../course/view.php?id=$course->id>$course->shortname</A> -> ". |
24 | get_string("participants"), ""); |
f9903ed0 |
25 | } else { |
fa0626c6 |
26 | print_header("$course->shortname: ".get_string("participants"), "$course->fullname", |
27 | get_string("participants"), ""); |
f9903ed0 |
28 | } |
29 | |
cd052f8c |
30 | $string->email = get_string("email"); |
31 | $string->location = get_string("location"); |
32 | $string->lastaccess = get_string("lastaccess"); |
33 | $string->activity = get_string("activity"); |
34 | $string->unenrol = get_string("unenrol"); |
35 | $string->loginas = get_string("loginas"); |
36 | $string->fullprofile = get_string("fullprofile"); |
40a1d986 |
37 | $string->role = get_string("role"); |
38 | $string->never = get_string("never"); |
6b281f1f |
39 | $string->name = get_string("name"); |
f9903ed0 |
40 | |
4b232245 |
41 | if ( $teachers = get_course_teachers($course->id)) { |
b4d7002e |
42 | echo "<H2 align=center>$course->teachers</H2>"; |
f9903ed0 |
43 | foreach ($teachers as $teacher) { |
f144c305 |
44 | if ($teacher->authority > 0) { // Don't print teachers with no authority |
45 | print_user($teacher, $course, $string); |
46 | } |
f9903ed0 |
47 | } |
f9903ed0 |
48 | } |
49 | |
6b281f1f |
50 | if ($students = get_course_students($course->id, "$sort $dir")) { |
6abee989 |
51 | $numstudents = count($students); |
52 | echo "<H2 align=center>$numstudents $course->students</H2>"; |
32b4b974 |
53 | if ($numstudents < $USER_SMALL_CLASS) { |
6abee989 |
54 | foreach ($students as $student) { |
55 | print_user($student, $course, $string); |
56 | } |
6b281f1f |
57 | } else { // Print one big table with abbreviated info |
32b4b974 |
58 | if ($sort == "u.firstname") { |
59 | $name = "$string->name"; |
60 | $location = "<A HREF=\"index.php?id=$course->id&sort=u.country&dir=ASC\">$string->location</A>"; |
61 | $lastaccess = "<A HREF=\"index.php?id=$course->id&sort=u.lastaccess&dir=DESC\">$string->lastaccess</A>"; |
62 | } else if ($sort == "u.country") { |
63 | $name = "<A HREF=\"index.php?id=$course->id&sort=u.firstname&dir=ASC\">$string->name</A>"; |
64 | $location = "$string->location"; |
65 | $lastaccess = "<A HREF=\"index.php?id=$course->id&sort=u.lastaccess&dir=DESC\">$string->lastaccess</A>"; |
66 | } else { |
67 | $name = "<A HREF=\"index.php?id=$course->id&sort=u.firstname&dir=ASC\">$string->name</A>"; |
68 | $location = "<A HREF=\"index.php?id=$course->id&sort=u.country&dir=ASC\">$string->location</A>"; |
69 | $lastaccess = "$string->lastaccess"; |
70 | } |
71 | $table->head = array (" ", $name, $location, $lastaccess); |
6b281f1f |
72 | $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT"); |
c69ce08b |
73 | $table->size = array ("10", "*", "*", "*"); |
6b281f1f |
74 | |
6abee989 |
75 | foreach ($students as $student) { |
6b281f1f |
76 | if ($student->lastaccess) { |
77 | $lastaccess = userdate($student->lastaccess); |
78 | $lastaccess .= "  (".format_time(time() - $student->lastaccess).")"; |
79 | } else { |
80 | $lastaccess = $string->never; |
81 | } |
82 | |
c69ce08b |
83 | if ($numstudents > $USER_LARGE_CLASS) { // Don't show pictures |
84 | $picture = ""; |
85 | } else { |
86 | $picture = print_user_picture($student->id, $course->id, $student->picture, false, true); |
87 | } |
88 | |
89 | $table->data[] = array ($picture, |
e6b9ee04 |
90 | "<B><A HREF=\"$CFG->wwwroot/user/view.php?id=$student->id&course=$course->id\">$student->firstname $student->lastname</A></B>", |
25fa226d |
91 | "<FONT SIZE=1>$student->city, ".$COUNTRIES["$student->country"]."</FONT>", |
92 | "<FONT SIZE=1>$lastaccess</FONT>"); |
6abee989 |
93 | } |
6b281f1f |
94 | print_table($table, 2, 0); |
f9903ed0 |
95 | } |
619431ba |
96 | } |
f9903ed0 |
97 | |
98 | print_footer($course); |
99 | |
f9903ed0 |
100 | ?> |