Improvements to the help system
[moodle.git] / course / user.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3 require("../config.php");
4
5 require_variable($id); // course id
6 require_variable($user); // user id
7
8 if (! $course = get_record("course", "id", $id)) {
9 error("Course id is incorrect.");
10 }
11
12 require_login($course->id);
13
14 if (!isteacher($course->id)) {
15 error("Only teachers can look at this page");
16 }
17
18 if (! $user = get_record("user", "id", $user)) {
19 error("User ID is incorrect");
20 }
21
600149be 22 add_to_log($course->id, "course", "user record", "user.php?id=$course->id&user=$user->id", "$user->id");
f9903ed0 23
24 print_header("$course->shortname: Report", "$course->fullname",
25 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
26 <A HREF=\"../user/index.php?id=$course->id\">Participants</A> ->
27 <A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> ->
28 Full Report", "");
29
600149be 30 if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
31 FROM modules m, course_modules cm
32 WHERE cm.course = '$course->id'
33 AND cm.deleted = '0'
34 AND cm.module = m.id") ) {
35
36 foreach($rawmods as $mod) { // Index the mods
37 $mods[$mod->id] = $mod;
38 $modtype[$mod->modname] = $mod->modfullname;
39 }
40 }
41
42
43 // Replace all the following with a better log-based method.
b5fe4c93 44 if ($course->format == "weeks") {
45 if ($sections = get_records_sql("SELECT * FROM course_sections WHERE course = '$course->id' ORDER BY section")) {
46 foreach ($sections as $www) {
47 $section = (object)$www;
48 echo "<H2>Week $section->section</H2>";
49 if ($section->sequence) {
50 $sectionmods = explode(",", $section->sequence);
51 foreach ($sectionmods as $sectionmod) {
52 $mod = $mods[$sectionmod];
600149be 53 $instance = get_record("$mod->modname", "id", "$mod->instance");
54 $userfile = "$CFG->dirroot/mod/$mod->name/user.php";
55 include($userfile);
56 }
57
58 } else {
59 echo "<P>No modules</P>";
60 }
f9903ed0 61 }
62 }
600149be 63 } else {
64 echo "<P>Not implemented yet</P>";
f9903ed0 65 }
66
67 print_footer($course);
68
69?>
70