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