2004-09-12 12:21:27 +00:00
|
|
|
<?php // $Id$
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-11 15:41:54 +00:00
|
|
|
// Display user activity reports for a course
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../config.php");
|
|
|
|
require_once("lib.php");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-05-24 07:33:22 +00:00
|
|
|
$modes = array("outline", "complete", "todaylogs", "alllogs");
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
require_variable($id); // course id
|
|
|
|
require_variable($user); // user id
|
2003-07-24 02:29:59 +00:00
|
|
|
optional_variable($mode, "todaylogs");
|
2003-08-22 06:07:18 +00:00
|
|
|
optional_variable($page, "0");
|
|
|
|
optional_variable($perpage, "100");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-05-24 07:33:22 +00:00
|
|
|
require_login();
|
2002-08-08 16:22:44 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course id is incorrect.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $user = get_record("user", "id", $user)) {
|
|
|
|
error("User ID is incorrect");
|
|
|
|
}
|
|
|
|
|
2003-10-31 06:45:38 +00:00
|
|
|
if (! (isteacher($course->id) or ($course->showreports and $USER->id == $user->id))) {
|
|
|
|
error("You are not allowed to look at this page");
|
|
|
|
}
|
|
|
|
|
2004-09-16 17:13:57 +00:00
|
|
|
add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-08 16:22:44 +00:00
|
|
|
$stractivityreport = get_string("activityreport");
|
|
|
|
$strparticipants = get_string("participants");
|
|
|
|
$stroutline = get_string("outline");
|
|
|
|
$strcomplete = get_string("complete");
|
|
|
|
$stralllogs = get_string("alllogs");
|
|
|
|
$strtodaylogs = get_string("todaylogs");
|
|
|
|
$strmode = get_string($mode);
|
2003-11-28 11:06:53 +00:00
|
|
|
$fullname = fullname($user, true);
|
2002-08-08 16:22:44 +00:00
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
print_header("$course->shortname: $stractivityreport ($mode)", "$course->fullname",
|
2004-09-12 12:21:27 +00:00
|
|
|
"<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
<a href=\"../user/index.php?id=$course->id\">$strparticipants</a> ->
|
2004-09-16 17:13:57 +00:00
|
|
|
<a href=\"../user/view.php?id=$user->id&course=$course->id\">$fullname</a> ->
|
2002-08-08 16:22:44 +00:00
|
|
|
$stractivityreport -> $strmode");
|
|
|
|
} else {
|
|
|
|
print_header("$course->shortname: $stractivityreport ($mode)", "$course->fullname",
|
2004-09-16 17:13:57 +00:00
|
|
|
"<a href=\"../user/view.php?id=$user->id&course=$course->id\">$fullname</a> ->
|
2002-08-08 16:22:44 +00:00
|
|
|
$stractivityreport -> $strmode");
|
|
|
|
}
|
2005-03-20 12:02:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// Print tabs at top
|
|
|
|
/// This same call is made in:
|
|
|
|
/// /user/view.php
|
|
|
|
/// /user/edit.php
|
|
|
|
/// /course/user.php
|
|
|
|
$currenttab = $mode;
|
|
|
|
include($CFG->dirroot.'/user/tabs.php');
|
|
|
|
|
2002-07-23 16:48:47 +00:00
|
|
|
|
2002-12-29 17:32:32 +00:00
|
|
|
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
2002-05-31 09:34:50 +00:00
|
|
|
|
2002-07-23 16:24:12 +00:00
|
|
|
switch ($mode) {
|
2002-08-08 16:22:44 +00:00
|
|
|
case "todaylogs" :
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '<div class="graph">';
|
2002-08-08 17:29:22 +00:00
|
|
|
print_log_graph($course, $user->id, "userday.png");
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '</div>';
|
2003-08-22 06:07:18 +00:00
|
|
|
print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage,
|
2004-09-16 17:13:57 +00:00
|
|
|
"user.php?id=$course->id&user=$user->id&mode=$mode");
|
2002-07-27 09:44:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "alllogs" :
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '<div class="graph">';
|
2002-07-27 09:44:01 +00:00
|
|
|
print_log_graph($course, $user->id, "usercourse.png");
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '</div>';
|
2003-08-22 06:07:18 +00:00
|
|
|
print_log($course, $user->id, 0, "l.time DESC", $page, $perpage,
|
2004-09-16 17:13:57 +00:00
|
|
|
"user.php?id=$course->id&user=$user->id&mode=$mode");
|
2002-07-23 16:24:12 +00:00
|
|
|
break;
|
2002-05-31 09:34:50 +00:00
|
|
|
|
2002-07-23 16:24:12 +00:00
|
|
|
case "outline" :
|
|
|
|
case "complete" :
|
|
|
|
default:
|
|
|
|
$sections = get_all_sections($course->id);
|
2002-05-31 09:34:50 +00:00
|
|
|
|
2002-07-23 16:24:12 +00:00
|
|
|
for ($i=0; $i<=$course->numsections; $i++) {
|
|
|
|
|
|
|
|
if (isset($sections[$i])) { // should always be true
|
|
|
|
|
|
|
|
$section = $sections[$i];
|
2004-11-16 17:30:45 +00:00
|
|
|
$showsection = (isteacher($course->id) or $section->visible or !$course->hiddensections);
|
2002-07-23 16:24:12 +00:00
|
|
|
|
2004-11-16 17:30:45 +00:00
|
|
|
if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert!
|
2002-07-23 16:24:12 +00:00
|
|
|
|
2004-11-16 17:30:45 +00:00
|
|
|
if ($section->sequence) {
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '<div class="section">';
|
|
|
|
echo '<h2>';
|
2004-11-16 17:30:45 +00:00
|
|
|
switch ($course->format) {
|
|
|
|
case "weeks": print_string("week"); break;
|
|
|
|
case "topics": print_string("topic"); break;
|
|
|
|
default: print_string("section"); break;
|
2003-01-14 14:56:57 +00:00
|
|
|
}
|
2004-11-16 17:30:45 +00:00
|
|
|
echo " $i</h2>";
|
|
|
|
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '<div class="content">';
|
2004-10-02 15:29:49 +00:00
|
|
|
|
2004-11-16 17:30:45 +00:00
|
|
|
if ($mode == "outline") {
|
|
|
|
echo "<table cellpadding=\"4\" cellspacing=\"0\">";
|
2004-10-02 15:29:49 +00:00
|
|
|
}
|
|
|
|
|
2004-11-16 17:30:45 +00:00
|
|
|
$sectionmods = explode(",", $section->sequence);
|
|
|
|
foreach ($sectionmods as $sectionmod) {
|
|
|
|
if (empty($mods[$sectionmod])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$mod = $mods[$sectionmod];
|
|
|
|
|
|
|
|
if (empty($mod->visible)) {
|
|
|
|
continue;
|
|
|
|
}
|
2002-07-25 13:47:11 +00:00
|
|
|
|
2004-11-16 17:30:45 +00:00
|
|
|
$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 = "<img src=\"../mod/$mod->modname/icon.gif\" ".
|
|
|
|
"height=\"16\" width=\"16\" alt=\"$mod->modfullname\" />";
|
|
|
|
echo "<h4>$image $mod->modfullname: ".
|
|
|
|
"<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
|
2005-04-14 22:41:19 +00:00
|
|
|
format_string($instance->name,true)."</a></h4>";
|
2004-11-16 17:30:45 +00:00
|
|
|
echo "<ul>";
|
|
|
|
$user_complete($course, $user, $mod, $instance);
|
|
|
|
echo "</ul>";
|
|
|
|
}
|
|
|
|
break;
|
2002-07-25 13:47:11 +00:00
|
|
|
}
|
2004-11-16 17:30:45 +00:00
|
|
|
}
|
2002-07-23 16:24:12 +00:00
|
|
|
}
|
2004-11-16 17:30:45 +00:00
|
|
|
|
|
|
|
if ($mode == "outline") {
|
|
|
|
echo "</table>";
|
|
|
|
print_simple_box_end();
|
2002-07-23 16:24:12 +00:00
|
|
|
}
|
2005-03-20 12:02:14 +00:00
|
|
|
echo '</div>'; // content
|
|
|
|
echo '</div>'; // section
|
2002-07-23 16:24:12 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-31 09:34:50 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2002-07-23 16:24:12 +00:00
|
|
|
break;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2002-07-23 16:24:12 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
2002-07-23 16:24:12 +00:00
|
|
|
|
2002-07-25 13:47:11 +00:00
|
|
|
function print_outline_row($mod, $instance, $result) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$image = "<img src=\"../mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\" />";
|
2004-09-12 12:21:27 +00:00
|
|
|
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td valign=\"top\">$image</td>";
|
|
|
|
echo "<td valign=\"top\" width=\"300\">";
|
|
|
|
echo " <a title=\"$mod->modfullname\"";
|
2005-04-14 22:41:19 +00:00
|
|
|
echo " href=\"../mod/$mod->modname/view.php?id=$mod->id\">".format_string($instance->name,true)."</a></td>";
|
2004-09-12 12:21:27 +00:00
|
|
|
echo "<td> </td>";
|
|
|
|
echo "<td valign=\"top\" bgcolor=\"white\">";
|
2002-07-25 13:47:11 +00:00
|
|
|
if (isset($result->info)) {
|
|
|
|
echo "$result->info";
|
|
|
|
} else {
|
2004-09-12 12:21:27 +00:00
|
|
|
echo "<p align=\"center\">-</p>";
|
2002-07-25 13:47:11 +00:00
|
|
|
}
|
2004-09-12 12:21:27 +00:00
|
|
|
echo "</td>";
|
|
|
|
echo "<td> </td>";
|
2002-07-25 13:47:11 +00:00
|
|
|
if (isset($result->time)) {
|
|
|
|
$timeago = format_time(time() - $result->time);
|
2004-09-12 12:21:27 +00:00
|
|
|
echo "<td valign=\"top\" nowrap=\"nowrap\">".userdate($result->time)." ($timeago)</td>";
|
2002-07-25 13:47:11 +00:00
|
|
|
}
|
2004-09-12 12:21:27 +00:00
|
|
|
echo "</tr>";
|
2002-07-23 16:24:12 +00:00
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
?>
|
|
|
|
|