Logs can now be divided up by activity!
This commit is contained in:
+55
-10
@@ -21,7 +21,8 @@ define("FRONTPAGECOURSELIST", 1);
|
||||
define("FRONTPAGECATEGORYNAMES", 2);
|
||||
|
||||
|
||||
function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") {
|
||||
function print_log_selector_form($course, $selecteduser=0, $selecteddate="today",
|
||||
$mod="", $modpage="", $modid=0) {
|
||||
|
||||
global $USER, $CFG;
|
||||
|
||||
@@ -58,6 +59,38 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
asort($courses);
|
||||
}
|
||||
|
||||
$activities = array();
|
||||
$selectedactivity = "";
|
||||
|
||||
if ($modinfo = unserialize($course->modinfo)) {
|
||||
$section = 0;
|
||||
if ($course->format == 'weeks') { // Bodgy
|
||||
$strsection = get_string("week");
|
||||
} else {
|
||||
$strsection = get_string("topic");
|
||||
}
|
||||
foreach ($modinfo as $mod) {
|
||||
if ($mod->mod == "label") {
|
||||
continue;
|
||||
}
|
||||
if ($mod->section > 0 and $section <> $mod->section) {
|
||||
$activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------";
|
||||
}
|
||||
$section = $mod->section;
|
||||
$mod->name = urldecode($mod->name);
|
||||
if (strlen($mod->name) > 55) {
|
||||
$mod->name = substr($mod->name, 0, 50)."...";
|
||||
}
|
||||
if (!$mod->visible) {
|
||||
$mod->name = "(".$mod->name.")";
|
||||
}
|
||||
$activities["$mod->mod/view.php?id=$mod->cm"] = $mod->name;
|
||||
|
||||
if ($mod->cm == $modid) {
|
||||
$selectedactivity = "$mod->mod/view.php?id=$mod->cm";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$strftimedate = get_string("strftimedate");
|
||||
$strftimedaydate = get_string("strftimedaydate");
|
||||
@@ -92,19 +125,20 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
$selecteddate = $today;
|
||||
}
|
||||
|
||||
echo "<CENTER>";
|
||||
echo "<FORM ACTION=log.php METHOD=get>";
|
||||
echo "<INPUT TYPE=hidden NAME=chooselog VALUE=\"1\">";
|
||||
echo '<center>';
|
||||
echo '<form action="log.php" method="get">';
|
||||
echo '<input type=hidden name=chooselog value="1">';
|
||||
if (isadmin()) {
|
||||
choose_from_menu ($courses, "id", $course->id, "");
|
||||
} else {
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
echo "<input type=hidden name=id value=\"$course->id\">";
|
||||
}
|
||||
choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
|
||||
choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
|
||||
echo "<INPUT TYPE=submit VALUE=\"".get_string("showtheselogs")."\">";
|
||||
echo "</FORM>";
|
||||
echo "</CENTER>";
|
||||
choose_from_menu ($activities, "url", $selectedactivity, get_string("allactivities"), "", "");
|
||||
echo "<input type=submit value=\"".get_string("showtheselogs")."\">";
|
||||
echo "</form>";
|
||||
echo "</center>";
|
||||
}
|
||||
|
||||
function make_log_url($module, $url) {
|
||||
@@ -124,11 +158,13 @@ function make_log_url($module, $url) {
|
||||
}
|
||||
|
||||
|
||||
function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100, $url="") {
|
||||
function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
|
||||
$url="", $mod="", $modpage="", $modid=0) {
|
||||
|
||||
// It is assumed that $date is the GMT time of midnight for that day,
|
||||
// and so the next 86400 seconds worth of logs are printed.
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $db;
|
||||
|
||||
if ($course->category) {
|
||||
$selector = "l.course='$course->id' AND l.userid = u.id";
|
||||
@@ -142,6 +178,14 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
|
||||
}
|
||||
}
|
||||
|
||||
if ($mod) {
|
||||
$selector .= " AND l.module = '$mod'";
|
||||
}
|
||||
|
||||
if ($modpage and $modid) {
|
||||
$selector .= " AND l.url = '$modpage.php?id=$modid'";
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$selector .= " AND l.userid = '$user'";
|
||||
}
|
||||
@@ -151,6 +195,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
|
||||
$selector .= " AND l.time > '$date' AND l.time < '$enddate'";
|
||||
}
|
||||
|
||||
|
||||
$totalcount = 0; // Initialise
|
||||
|
||||
if (!$logs = get_logs($selector, $order, $page*$perpage, $perpage, $totalcount)) {
|
||||
|
||||
+26
-11
@@ -7,6 +7,7 @@
|
||||
require_variable($id); // Course ID
|
||||
optional_variable($user, 0); // User to display
|
||||
optional_variable($date, 0); // Date to display
|
||||
optional_variable($url, ""); // eg resource/view.php?id=66
|
||||
optional_variable($page, "0"); // which page to show
|
||||
optional_variable($perpage, "100"); // how many per page
|
||||
|
||||
@@ -44,42 +45,56 @@
|
||||
$dateinfo = userdate($date, get_string("strftimedaydate"));
|
||||
}
|
||||
|
||||
if ($url) { // parse into parts: resource/view.php?id=66
|
||||
$urlraw = urldecode($url);
|
||||
$urlparts = split("/", $urlraw);
|
||||
if ($urlparts[0] != "section" and $urlparts[0] != "") {
|
||||
$modname = $urlparts[0];
|
||||
$modparts = split('.php\?id=', $urlparts[1]);
|
||||
if (count($modparts) == 2) {
|
||||
$modpage = $modparts[0];
|
||||
$modid = $modparts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($course->category) {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
|
||||
<A HREF=\"log.php?id=$course->id\">$strlogs</A> -> $userinfo, $dateinfo", "");
|
||||
"<a href=\"view.php?id=$course->id\">$course->shortname</a> ->
|
||||
<a href=\"log.php?id=$course->id\">$strlogs</a> -> $userinfo, $dateinfo", "");
|
||||
} else {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"log.php?id=$course->id\">$strlogs</A> -> $userinfo, $dateinfo", "");
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> ->
|
||||
<a href=\"log.php?id=$course->id\">$strlogs</a> -> $userinfo, $dateinfo", "");
|
||||
}
|
||||
|
||||
print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
|
||||
|
||||
print_log_selector_form($course, $user, $date);
|
||||
print_log_selector_form($course, $user, $date, $modname, $modpage, $modid);
|
||||
|
||||
print_log($course, $user, $date, "l.time DESC", $page, $perpage,
|
||||
"log.php?id=$course->id&chooselog=1&user=$user&date=$date");
|
||||
"log.php?id=$course->id&chooselog=1&user=$user&date=$date&url=$url",
|
||||
$modname, $modpage, $modid);
|
||||
|
||||
} else {
|
||||
if ($course->category) {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"view.php?id=$course->id\">$course->shortname</A> -> $strlogs", "");
|
||||
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strlogs", "");
|
||||
} else {
|
||||
print_header("$course->shortname: $strlogs", "$course->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strlogs", "");
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strlogs", "");
|
||||
}
|
||||
|
||||
print_heading(get_string("chooselogs").":");
|
||||
|
||||
print_log_selector_form($course);
|
||||
|
||||
echo "<BR>";
|
||||
echo "<br />";
|
||||
print_heading(get_string("chooselivelogs").":");
|
||||
|
||||
echo "<CENTER><H3>";
|
||||
echo "<center><h3>";
|
||||
link_to_popup_window("/course/loglive.php?id=$course->id","livelog", get_string("livelogs"), 500, 800);
|
||||
echo "</H3></CENTER>";
|
||||
echo "</h3></center>";
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
Reference in New Issue
Block a user