f9903ed0 |
1 | <?PHP // $Id$ |
2 | |
97c270e9 |
3 | // Display user activity reports for a course |
4 | |
b0e3a925 |
5 | require_once("../config.php"); |
6 | require_once("lib.php"); |
f9903ed0 |
7 | |
40343df7 |
8 | $modes = array("outline", "complete", "todaylogs", "alllogs"); |
9 | |
f9903ed0 |
10 | require_variable($id); // course id |
11 | require_variable($user); // user id |
0ed00b3b |
12 | optional_variable($mode, "todaylogs"); |
519d369f |
13 | optional_variable($page, "0"); |
14 | optional_variable($perpage, "100"); |
f9903ed0 |
15 | |
40343df7 |
16 | require_login(); |
a2ab3b05 |
17 | |
f9903ed0 |
18 | if (! $course = get_record("course", "id", $id)) { |
19 | error("Course id is incorrect."); |
20 | } |
21 | |
3f125001 |
22 | if (! (isteacher($course->id) or ($course->showreports and $USER->id == $user))) { |
40343df7 |
23 | error("You are not allowed to look at this page"); |
24 | } |
f9903ed0 |
25 | |
f9903ed0 |
26 | if (! $user = get_record("user", "id", $user)) { |
27 | error("User ID is incorrect"); |
28 | } |
29 | |
359b138b |
30 | add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id"); |
f9903ed0 |
31 | |
a2ab3b05 |
32 | $stractivityreport = get_string("activityreport"); |
33 | $strparticipants = get_string("participants"); |
34 | $stroutline = get_string("outline"); |
35 | $strcomplete = get_string("complete"); |
36 | $stralllogs = get_string("alllogs"); |
37 | $strtodaylogs = get_string("todaylogs"); |
38 | $strmode = get_string($mode); |
39 | |
40 | if ($course->category) { |
41 | print_header("$course->shortname: $stractivityreport ($mode)", "$course->fullname", |
f9903ed0 |
42 | "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> -> |
a2ab3b05 |
43 | <A HREF=\"../user/index.php?id=$course->id\">$strparticipants</A> -> |
f9903ed0 |
44 | <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> -> |
a2ab3b05 |
45 | $stractivityreport -> $strmode"); |
46 | } else { |
47 | print_header("$course->shortname: $stractivityreport ($mode)", "$course->fullname", |
48 | "<A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> -> |
49 | $stractivityreport -> $strmode"); |
50 | } |
bbfe835b |
51 | print_heading("$user->firstname $user->lastname"); |
52 | |
40343df7 |
53 | echo "<table cellpadding=10 align=center><tr>"; |
350a05c4 |
54 | echo "<td>$stractivityreport: </td>"; |
40343df7 |
55 | |
a2ab3b05 |
56 | foreach ($modes as $listmode) { |
57 | $strmode = get_string($listmode); |
58 | if ($mode == $listmode) { |
40343df7 |
59 | echo "<td><u>$strmode</u></td>"; |
a2ab3b05 |
60 | } else { |
40343df7 |
61 | echo "<td><a href=user.php?id=$course->id&user=$user->id&mode=$listmode>$strmode</a></td>"; |
a2ab3b05 |
62 | } |
2b8cef80 |
63 | } |
40343df7 |
64 | echo "</tr></table>"; |
bbfe835b |
65 | |
9c9f7d77 |
66 | get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); |
600149be |
67 | |
7468bf01 |
68 | switch ($mode) { |
a2ab3b05 |
69 | case "todaylogs" : |
2b8cef80 |
70 | echo "<HR><CENTER>"; |
adecd142 |
71 | print_log_graph($course, $user->id, "userday.png"); |
2b8cef80 |
72 | echo "</CENTER>"; |
519d369f |
73 | print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, |
74 | "user.php?id=$course->id&user=$user->id&mode=$mode"); |
2b8cef80 |
75 | break; |
76 | |
77 | case "alllogs" : |
78 | echo "<HR><CENTER>"; |
79 | print_log_graph($course, $user->id, "usercourse.png"); |
80 | echo "</CENTER>"; |
519d369f |
81 | print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, |
82 | "user.php?id=$course->id&user=$user->id&mode=$mode"); |
7468bf01 |
83 | break; |
600149be |
84 | |
7468bf01 |
85 | case "outline" : |
86 | case "complete" : |
87 | default: |
88 | $sections = get_all_sections($course->id); |
600149be |
89 | |
7468bf01 |
90 | for ($i=0; $i<=$course->numsections; $i++) { |
91 | |
92 | if (isset($sections[$i])) { // should always be true |
93 | |
94 | $section = $sections[$i]; |
95 | |
96 | if ($section->sequence) { |
97 | echo "<HR>"; |
98 | echo "<H2>"; |
99 | switch ($course->format) { |
100 | case "weeks": print_string("week"); break; |
101 | case "topics": print_string("topic"); break; |
102 | default: print_string("section"); break; |
103 | } |
104 | echo " $i</H2>"; |
105 | |
106 | echo "<UL>"; |
107 | |
108 | if ($mode == "outline") { |
109 | echo "<TABLE CELLPADDING=4 CELLSPACING=0>"; |
110 | } |
111 | |
112 | $sectionmods = explode(",", $section->sequence); |
113 | foreach ($sectionmods as $sectionmod) { |
7af6281f |
114 | if (empty($mods[$sectionmod])) { |
115 | continue; |
116 | } |
7468bf01 |
117 | $mod = $mods[$sectionmod]; |
118 | $instance = get_record("$mod->modname", "id", "$mod->instance"); |
359b138b |
119 | $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php"; |
120 | |
121 | if (file_exists($libfile)) { |
122 | require_once($libfile); |
123 | |
124 | switch ($mode) { |
125 | case "outline": |
126 | $user_outline = $mod->modname."_user_outline"; |
127 | if (function_exists($user_outline)) { |
128 | $output = $user_outline($course, $user, $mod, $instance); |
129 | print_outline_row($mod, $instance, $output); |
130 | } |
131 | break; |
132 | case "complete": |
133 | $user_complete = $mod->modname."_user_complete"; |
134 | if (function_exists($user_complete)) { |
135 | $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" ". |
136 | "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; |
137 | echo "<H4>$image $mod->modfullname: ". |
138 | "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". |
139 | "$instance->name</A></H4>"; |
140 | echo "<UL>"; |
141 | $user_complete($course, $user, $mod, $instance); |
142 | echo "</UL>"; |
143 | } |
144 | break; |
7468bf01 |
145 | } |
146 | } |
147 | } |
148 | |
149 | if ($mode == "outline") { |
150 | echo "</TABLE>"; |
151 | print_simple_box_end(); |
152 | } |
153 | echo "</UL>"; |
359b138b |
154 | |
600149be |
155 | |
7468bf01 |
156 | } |
600149be |
157 | } |
f9903ed0 |
158 | } |
7468bf01 |
159 | break; |
f9903ed0 |
160 | } |
161 | |
7468bf01 |
162 | |
f9903ed0 |
163 | print_footer($course); |
164 | |
7468bf01 |
165 | |
359b138b |
166 | function print_outline_row($mod, $instance, $result) { |
7468bf01 |
167 | $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; |
49a6849e |
168 | |
359b138b |
169 | echo "<TR>"; |
170 | echo "<TD VALIGN=top>$image</TD>"; |
49a6849e |
171 | echo "<TD VALIGN=top width=300>"; |
359b138b |
172 | echo " <A TITLE=\"$mod->modfullname\""; |
7468bf01 |
173 | echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>"; |
174 | echo "<TD> </TD>"; |
359b138b |
175 | echo "<TD VALIGN=top BGCOLOR=white>"; |
176 | if (isset($result->info)) { |
177 | echo "$result->info"; |
178 | } else { |
179 | echo "<P ALIGN=CENTER>-</P>"; |
180 | } |
181 | echo "</TD>"; |
182 | echo "<TD> </TD>"; |
183 | if (isset($result->time)) { |
184 | $timeago = format_time(time() - $result->time); |
2a231ed6 |
185 | echo "<TD VALIGN=top NOWRAP>".userdate($result->time)." ($timeago)</TD>"; |
359b138b |
186 | } |
187 | echo "</TR>"; |
7468bf01 |
188 | } |
189 | |
f9903ed0 |
190 | ?> |
191 | |