cough
[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
f9903ed0 16 if (! $user = get_record("user", "id", $user)) {
17 error("User ID is incorrect");
18 }
19
5110affb 20 if (!isteacher($course->id) and $user->id != $USER->id ) {
21 error("You are not allowed to look at this page");
22 }
23
24
600149be 25 add_to_log($course->id, "course", "user record", "user.php?id=$course->id&user=$user->id", "$user->id");
f9903ed0 26
bbfe835b 27 print_header("$course->shortname: Activity Report", "$course->fullname",
f9903ed0 28 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
29 <A HREF=\"../user/index.php?id=$course->id\">Participants</A> ->
30 <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> ->
bbfe835b 31 Activity Report ($mode)", "");
32 print_heading("$user->firstname $user->lastname");
33
34 echo "<TABLE CELLPADDING=10 ALIGN=CENTER><TR>";
6ee410e3 35 echo "<TD>Reports: </TD>";
bbfe835b 36 if ($mode != "summary") {
37 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=summary>Summary</A></TD>";
38 } else {
56e234f2 39 echo "<TD><U>Summary</U></TD>";
bbfe835b 40 }
41 if ($mode != "outline") {
42 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=outline>Outline</A></TD>";
43 } else {
56e234f2 44 echo "<TD><U>Outline</U></TD>";
bbfe835b 45 }
46 if ($mode != "complete") {
47 echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=complete>Complete</A></TD>";
48 } else {
56e234f2 49 echo "<TD><U>Complete</U></TD>";
bbfe835b 50 }
51 echo "</TR></TABLE>";
52
f9903ed0 53
7468bf01 54 get_all_mods($course->id, $mods, $modtype);
600149be 55
7468bf01 56 switch ($mode) {
57 case "summary" :
82f5285f 58 echo "<P>Not done yet</P>";
59 echo "<P>Graph goes here that shows accesses by day over the course</P>";
60 echo "<HR>";
61 echo "<P>Table goes here that summarises all activity by this student by module. eg 3/7 journals done, 3/3 surveys, 12 posts in all discussions. Each of these are links so that you can drill down to see all the surveys on one page, or all the posts, or all their journals.";
7468bf01 62 break;
600149be 63
7468bf01 64 case "outline" :
65 case "complete" :
66 default:
67 $sections = get_all_sections($course->id);
600149be 68
7468bf01 69 for ($i=0; $i<=$course->numsections; $i++) {
70
71 if (isset($sections[$i])) { // should always be true
72
73 $section = $sections[$i];
74
75 if ($section->sequence) {
76 echo "<HR>";
77 echo "<H2>";
78 switch ($course->format) {
79 case "weeks": print_string("week"); break;
80 case "topics": print_string("topic"); break;
81 default: print_string("section"); break;
82 }
83 echo " $i</H2>";
84
85 echo "<UL>";
86
87 if ($mode == "outline") {
88 echo "<TABLE CELLPADDING=4 CELLSPACING=0>";
89 }
90
91 $sectionmods = explode(",", $section->sequence);
92 foreach ($sectionmods as $sectionmod) {
93 $mod = $mods[$sectionmod];
94 $instance = get_record("$mod->modname", "id", "$mod->instance");
95 $userfile = "$CFG->dirroot/mod/$mod->modname/user.php";
96 if (file_exists($userfile)) {
97 if ($mode == "outline") {
98 $output = include($userfile);
99 print_outline_row($mod, $instance, $output);
100 } else {
82f5285f 101
102 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" ".
103 "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
5110affb 104 echo "<H4>$image $mod->modfullname: ".
82f5285f 105 "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
5110affb 106 "$instance->name</A></H4>";
82f5285f 107 echo "<UL>";
7468bf01 108 include($userfile);
82f5285f 109 echo "</UL>";
7468bf01 110 }
111 }
112 }
113
114 if ($mode == "outline") {
115 echo "</TABLE>";
116 print_simple_box_end();
117 }
118 echo "</UL>";
600149be 119
7468bf01 120 }
600149be 121 }
f9903ed0 122 }
7468bf01 123 break;
f9903ed0 124 }
125
7468bf01 126
f9903ed0 127 print_footer($course);
128
7468bf01 129
130function print_outline_row($mod, $instance, $info) {
131 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
49a6849e 132
bbfe835b 133 echo "<TR><TD VALIGN=top>$image</TD>";
49a6849e 134 echo "<TD VALIGN=top width=300>";
7468bf01 135 echo "<A TITLE=\"$mod->modfullname\"";
136 echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>";
137 echo "<TD>&nbsp;&nbsp;&nbsp;</TD>";
49a6849e 138 echo "<TD VALIGN=top BGCOLOR=white>$info</TD></TR>";
7468bf01 139}
140
f9903ed0 141?>
142