Part of "contributions" overhaul in course/user.php
[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
7468bf01 8 optional_variable($mode, "complete");
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
26 print_header("$course->shortname: Report", "$course->fullname",
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> ->
30 Full Report", "");
31
7468bf01 32 get_all_mods($course->id, $mods, $modtype);
600149be 33
7468bf01 34 switch ($mode) {
35 case "summary" :
36 echo "<P>Not supported yet</P>";
37 break;
600149be 38
7468bf01 39 case "outline" :
40 case "complete" :
41 default:
42 $sections = get_all_sections($course->id);
600149be 43
7468bf01 44 for ($i=0; $i<=$course->numsections; $i++) {
45
46 if (isset($sections[$i])) { // should always be true
47
48 $section = $sections[$i];
49
50 if ($section->sequence) {
51 echo "<HR>";
52 echo "<H2>";
53 switch ($course->format) {
54 case "weeks": print_string("week"); break;
55 case "topics": print_string("topic"); break;
56 default: print_string("section"); break;
57 }
58 echo " $i</H2>";
59
60 echo "<UL>";
61
62 if ($mode == "outline") {
63 echo "<TABLE CELLPADDING=4 CELLSPACING=0>";
64 }
65
66 $sectionmods = explode(",", $section->sequence);
67 foreach ($sectionmods as $sectionmod) {
68 $mod = $mods[$sectionmod];
69 $instance = get_record("$mod->modname", "id", "$mod->instance");
70 $userfile = "$CFG->dirroot/mod/$mod->modname/user.php";
71 if (file_exists($userfile)) {
72 if ($mode == "outline") {
73 $output = include($userfile);
74 print_outline_row($mod, $instance, $output);
75 } else {
76 include($userfile);
77 }
78 }
79 }
80
81 if ($mode == "outline") {
82 echo "</TABLE>";
83 print_simple_box_end();
84 }
85 echo "</UL>";
600149be 86
7468bf01 87 }
600149be 88 }
f9903ed0 89 }
7468bf01 90 break;
f9903ed0 91 }
92
7468bf01 93
f9903ed0 94 print_footer($course);
95
7468bf01 96
97function print_outline_row($mod, $instance, $info) {
98 $image = "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
99 echo "<TR><TD ALIGN=right>$image</TD>";
100 echo "<TD align=left width=200>";
101 echo "<A TITLE=\"$mod->modfullname\"";
102 echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name</A></TD>";
103 echo "<TD>&nbsp;&nbsp;&nbsp;</TD>";
104 echo "<TD BGCOLOR=white>$info</TD></TR>";
105}
106
f9903ed0 107?>
108