Ch ch ch
[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" :
82f5285f 56 echo "<P>Not done yet</P>";
57 echo "<P>Graph goes here that shows accesses by day over the course</P>";
58 echo "<HR>";
59 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 60 break;
600149be 61
7468bf01 62 case "outline" :
63 case "complete" :
64 default:
65 $sections = get_all_sections($course->id);
600149be 66
7468bf01 67 for ($i=0; $i<=$course->numsections; $i++) {
68
69 if (isset($sections[$i])) { // should always be true
70
71 $section = $sections[$i];
72
73 if ($section->sequence) {
74 echo "<HR>";
75 echo "<H2>";
76 switch ($course->format) {
77 case "weeks": print_string("week"); break;
78 case "topics": print_string("topic"); break;
79 default: print_string("section"); break;
80 }
81 echo " $i</H2>";
82
83 echo "<UL>";
84
85 if ($mode == "outline") {
86 echo "<TABLE CELLPADDING=4 CELLSPACING=0>";
87 }
88
89 $sectionmods = explode(",", $section->sequence);
90 foreach ($sectionmods as $sectionmod) {
91 $mod = $mods[$sectionmod];
92 $instance = get_record("$mod->modname", "id", "$mod->instance");
93 $userfile = "$CFG->dirroot/mod/$mod->modname/user.php";
94 if (file_exists($userfile)) {
95 if ($mode == "outline") {
96 $output = include($userfile);
97 print_outline_row($mod, $instance, $output);
98 } else {
82f5285f 99
100 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" ".
101 "HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
102 echo "<H3>$image $mod->modfullname: ".
103 "<A HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
104 "$instance->name</A></H3>";
105 echo "<UL>";
7468bf01 106 include($userfile);
82f5285f 107 echo "</UL>";
7468bf01 108 }
109 }
110 }
111
112 if ($mode == "outline") {
113 echo "</TABLE>";
114 print_simple_box_end();
115 }
116 echo "</UL>";
600149be 117
7468bf01 118 }
600149be 119 }
f9903ed0 120 }
7468bf01 121 break;
f9903ed0 122 }
123
7468bf01 124
f9903ed0 125 print_footer($course);
126
7468bf01 127
128function print_outline_row($mod, $instance, $info) {
129 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
bbfe835b 130 echo "<TR><TD VALIGN=top>$image</TD>";
7468bf01 131 echo "<TD align=left width=200>";
132 echo "<A TITLE=\"$mod->modfullname\"";
133 echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>";
134 echo "<TD>&nbsp;&nbsp;&nbsp;</TD>";
135 echo "<TD BGCOLOR=white>$info</TD></TR>";
136}
137
f9903ed0 138?>
139