Improvements to activity reports
[moodle.git] / course / user.php
CommitLineData
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
bbfe835b 8 optional_variable($mode, "outline");
f9903ed0 9
10 if (! $course = get_record("course", "id", $id)) {
11 error("Course id is incorrect.");
12 }
13
14 require_login($course->id);
15
16 if (!isteacher($course->id)) {
17 error("Only teachers can look at this page");
18 }
19
20 if (! $user = get_record("user", "id", $user)) {
21 error("User ID is incorrect");
22 }
23
600149be 24 add_to_log($course->id, "course", "user record", "user.php?id=$course->id&user=$user->id", "$user->id");
f9903ed0 25
bbfe835b 26 print_header("$course->shortname: Activity Report", "$course->fullname",
f9903ed0 27 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
28 <A HREF=\"../user/index.php?id=$course->id\">Participants</A> ->
29 <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> ->
bbfe835b 30 Activity Report ($mode)", "");
31 print_heading("$user->firstname $user->lastname");
32
33 echo "<TABLE CELLPADDING=10 ALIGN=CENTER><TR>";
34 if ($mode != "summary") {
35 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=summary>Summary</A></TD>";
36 } else {
37 echo "<TD>Summary</TD>";
38 }
39 if ($mode != "outline") {
40 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=outline>Outline</A></TD>";
41 } else {
42 echo "<TD>Outline</TD>";
43 }
44 if ($mode != "complete") {
45 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=complete>Complete</A></TD>";
46 } else {
47 echo "<TD>Complete</TD>";
48 }
49 echo "</TR></TABLE>";
50
f9903ed0 51
7468bf01 52 get_all_mods($course->id, $mods, $modtype);
600149be 53
7468bf01 54 switch ($mode) {
55 case "summary" :
56 echo "<P>Not supported yet</P>";
57 break;
600149be 58
7468bf01 59 case "outline" :
60 case "complete" :
61 default:
62 $sections = get_all_sections($course->id);
600149be 63
7468bf01 64 for ($i=0; $i<=$course->numsections; $i++) {
65
66 if (isset($sections[$i])) { // should always be true
67
68 $section = $sections[$i];
69
70 if ($section->sequence) {
71 echo "<HR>";
72 echo "<H2>";
73 switch ($course->format) {
74 case "weeks": print_string("week"); break;
75 case "topics": print_string("topic"); break;
76 default: print_string("section"); break;
77 }
78 echo " $i</H2>";
79
80 echo "<UL>";
81
82 if ($mode == "outline") {
83 echo "<TABLE CELLPADDING=4 CELLSPACING=0>";
84 }
85
86 $sectionmods = explode(",", $section->sequence);
87 foreach ($sectionmods as $sectionmod) {
88 $mod = $mods[$sectionmod];
89 $instance = get_record("$mod->modname", "id", "$mod->instance");
90 $userfile = "$CFG->dirroot/mod/$mod->modname/user.php";
91 if (file_exists($userfile)) {
92 if ($mode == "outline") {
93 $output = include($userfile);
94 print_outline_row($mod, $instance, $output);
95 } else {
96 include($userfile);
97 }
98 }
99 }
100
101 if ($mode == "outline") {
102 echo "</TABLE>";
103 print_simple_box_end();
104 }
105 echo "</UL>";
600149be 106
7468bf01 107 }
600149be 108 }
f9903ed0 109 }
7468bf01 110 break;
f9903ed0 111 }
112
7468bf01 113
f9903ed0 114 print_footer($course);
115
7468bf01 116
117function print_outline_row($mod, $instance, $info) {
118 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
bbfe835b 119 echo "<TR><TD VALIGN=top>$image</TD>";
7468bf01 120 echo "<TD align=left width=200>";
121 echo "<A TITLE=\"$mod->modfullname\"";
122 echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>";
123 echo "<TD>&nbsp;&nbsp;&nbsp;</TD>";
124 echo "<TD BGCOLOR=white>$info</TD></TR>";
125}
126
f9903ed0 127?>
128