moodle/course/user.php
martin b5fe4c935d Major changes throughout to change "week" notation to "section" notation.
Sections covers "weeks", "topics" and anything else that may come along.
Note, again, some databases have changed esp course_weeks -> course_sections
and several fields called "week" are now "section.  Also course no longer
has an enddate, but instead has a numsections field.
2002-06-25 11:49:06 +00:00

71 lines
2.5 KiB
PHP

<?PHP // $Id$
require("../config.php");
require_variable($id); // course id
require_variable($user); // user id
if (! $course = get_record("course", "id", $id)) {
error("Course id is incorrect.");
}
require_login($course->id);
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (! $user = get_record("user", "id", $user)) {
error("User ID is incorrect");
}
add_to_log($course->id, "course", "user record", "user.php?id=$course->id&user=$user->id", "$user->id");
print_header("$course->shortname: Report", "$course->fullname",
"<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
<A HREF=\"../user/index.php?id=$course->id\">Participants</A> ->
<A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A> ->
Full Report", "");
if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
FROM modules m, course_modules cm
WHERE cm.course = '$course->id'
AND cm.deleted = '0'
AND cm.module = m.id") ) {
foreach($rawmods as $mod) { // Index the mods
$mods[$mod->id] = $mod;
$modtype[$mod->modname] = $mod->modfullname;
}
}
// Replace all the following with a better log-based method.
if ($course->format == "weeks") {
if ($sections = get_records_sql("SELECT * FROM course_sections WHERE course = '$course->id' ORDER BY section")) {
foreach ($sections as $www) {
$section = (object)$www;
echo "<H2>Week $section->section</H2>";
if ($section->sequence) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
$mod = $mods[$sectionmod];
$instance = get_record("$mod->modname", "id", "$mod->instance");
$userfile = "$CFG->dirroot/mod/$mod->name/user.php";
include($userfile);
}
} else {
echo "<P>No modules</P>";
}
}
}
} else {
echo "<P>Not implemented yet</P>";
}
print_footer($course);
?>