id);
if (! $user = get_record("user", "id", $user)) {
error("User ID is incorrect");
}
if (!isteacher($course->id) and $user->id != $USER->id ) {
error("You are not allowed to look at this page");
}
add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
print_header("$course->shortname: Activity Report ($mode)", "$course->fullname",
"id\">$course->shortname ->
id\">Participants ->
id&course=$course->id\">$user->firstname $user->lastname ->
Activity Report ($mode)", "");
print_heading("$user->firstname $user->lastname");
echo "
";
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
switch ($mode) {
case "today" :
echo "
";
print_log_graph($course, $user->id, "userday.png", time() );
echo "";
print_log($course, $user->id, usergetmidnight(time()), "ORDER BY l.time DESC");
break;
case "alllogs" :
echo "
";
print_log_graph($course, $user->id, "usercourse.png");
echo "";
print_log($course, $user->id, 0, "ORDER BY l.time DESC");
break;
case "outline" :
case "complete" :
default:
$sections = get_all_sections($course->id);
for ($i=0; $i<=$course->numsections; $i++) {
if (isset($sections[$i])) { // should always be true
$section = $sections[$i];
if ($section->sequence) {
echo "
";
echo "";
switch ($course->format) {
case "weeks": print_string("week"); break;
case "topics": print_string("topic"); break;
default: print_string("section"); break;
}
echo " $i
";
echo "";
if ($mode == "outline") {
echo "";
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
$mod = $mods[$sectionmod];
$instance = get_record("$mod->modname", "id", "$mod->instance");
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
if (file_exists($libfile)) {
require_once($libfile);
switch ($mode) {
case "outline":
$user_outline = $mod->modname."_user_outline";
if (function_exists($user_outline)) {
$output = $user_outline($course, $user, $mod, $instance);
print_outline_row($mod, $instance, $output);
}
break;
case "complete":
$user_complete = $mod->modname."_user_complete";
if (function_exists($user_complete)) {
$image = "modname/icon.gif\" ".
"HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo "";
echo "";
$user_complete($course, $user, $mod, $instance);
echo "
";
}
break;
}
}
}
if ($mode == "outline") {
echo "
";
print_simple_box_end();
}
echo "
";
}
}
}
break;
}
print_footer($course);
function print_outline_row($mod, $instance, $result) {
$image = "modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo "";
echo "$image | ";
echo "";
echo " modfullname\"";
echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instance->name | ";
echo " | ";
echo "";
if (isset($result->info)) {
echo "$result->info";
} else {
echo " - ";
}
echo " | ";
echo " | ";
if (isset($result->time)) {
$timeago = format_time(time() - $result->time);
echo "".userdate($result->time)." ($timeago ago) | ";
}
echo "
";
}
?>