3 // Display user activity reports for a course
5 require_once("../config.php");
6 require_once("lib.php");
8 $modes = array("outline", "complete", "todaylogs", "alllogs");
10 require_variable($id); // course id
11 require_variable($user); // user id
12 optional_variable($mode, "todaylogs");
13 optional_variable($page, "0");
14 optional_variable($perpage, "100");
18 if (! $course = get_record("course", "id", $id)) {
19 error("Course id is incorrect.");
22 if (!isteacher($course->id
)) {
23 error("You are not allowed to look at this page");
26 if (! $user = get_record("user", "id", $user)) {
27 error("User ID is incorrect");
30 add_to_log($course->id
, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
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);
40 if ($course->category
) {
41 print_header("$course->shortname: $stractivityreport ($mode)", "$course->fullname",
42 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
43 <A HREF=\"../user/index.php?id=$course->id\">$strparticipants</A> ->
44 <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> ->
45 $stractivityreport -> $strmode");
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");
51 print_heading("$user->firstname $user->lastname");
53 echo "<table cellpadding=10 align=center><tr>";
54 echo "<td>$stractivityreport: </td>";
56 foreach ($modes as $listmode) {
57 $strmode = get_string($listmode);
58 if ($mode == $listmode) {
59 echo "<td><u>$strmode</u></td>";
61 echo "<td><a href=user.php?id=$course->id&user=$user->id&mode=$listmode>$strmode</a></td>";
66 get_all_mods($course->id
, $mods, $modnames, $modnamesplural, $modnamesused);
71 print_log_graph($course, $user->id
, "userday.png");
73 print_log($course, $user->id
, usergetmidnight(time()), "l.time DESC", $page, $perpage,
74 "user.php?id=$course->id&user=$user->id&mode=$mode");
79 print_log_graph($course, $user->id
, "usercourse.png");
81 print_log($course, $user->id
, 0, "l.time DESC", $page, $perpage,
82 "user.php?id=$course->id&user=$user->id&mode=$mode");
88 $sections = get_all_sections($course->id
);
90 for ($i=0; $i<=$course->numsections
; $i++
) {
92 if (isset($sections[$i])) { // should always be true
94 $section = $sections[$i];
96 if ($section->sequence
) {
99 switch ($course->format
) {
100 case "weeks": print_string("week"); break;
101 case "topics": print_string("topic"); break;
102 default: print_string("section"); break;
108 if ($mode == "outline") {
109 echo "<TABLE CELLPADDING=4 CELLSPACING=0>";
112 $sectionmods = explode(",", $section->sequence
);
113 foreach ($sectionmods as $sectionmod) {
114 if (empty($mods[$sectionmod])) {
117 $mod = $mods[$sectionmod];
118 $instance = get_record("$mod->modname", "id", "$mod->instance");
119 $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
121 if (file_exists($libfile)) {
122 require_once($libfile);
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);
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>";
141 $user_complete($course, $user, $mod, $instance);
149 if ($mode == "outline") {
151 print_simple_box_end();
163 print_footer($course);
166 function print_outline_row($mod, $instance, $result) {
167 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
170 echo "<TD VALIGN=top>$image</TD>";
171 echo "<TD VALIGN=top width=300>";
172 echo " <A TITLE=\"$mod->modfullname\"";
173 echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>";
174 echo "<TD> </TD>";
175 echo "<TD VALIGN=top BGCOLOR=white>";
176 if (isset($result->info
)) {
177 echo "$result->info";
179 echo "<P ALIGN=CENTER>-</P>";
182 echo "<TD> </TD>";
183 if (isset($result->time
)) {
184 $timeago = format_time(time() - $result->time
);
185 echo "<TD VALIGN=top NOWRAP>".userdate($result->time
)." ($timeago)</TD>";