Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes to improve the user activity reports

  • Loading branch information...
commit 2b8cef80381adcaa3432ea82a34aee146a2a4b6a 1 parent cbc83a3
martin authored
Showing with 44 additions and 13 deletions.
  1. +5 −0 course/lib.php
  2. +15 −3 course/loggraph.php
  3. +24 −10 course/user.php
View
5 course/lib.php
@@ -424,4 +424,9 @@ function get_all_sections($courseid) {
ORDER BY section");
}
+function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
+ global $CFG;
+ echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
+}
+
?>
View
18 course/loggraph.php
@@ -7,6 +7,7 @@
require_variable($id); // Course ID
require_variable($type); // Graph Type
optional_variable($user); // Student ID
+ optional_variable($date); // Midnight of a date
if (! $course = get_record("course", "id", $id)) {
error("Course is misconfigured");
@@ -15,7 +16,7 @@
require_login($course->id);
if (!isteacher($course->id)) {
- if (! ($type == "student.png" and $user == $USER->id) ) {
+ if (! ($type == "usercourse.png" and $user == $USER->id) ) {
error("Sorry, you aren't allowed to see this.");
}
}
@@ -31,7 +32,7 @@
switch ($type) {
- case "user.png":
+ case "usercourse.png":
$timestart = $course->startdate;
$i = 0;
@@ -51,7 +52,7 @@
$maxlogs = max($logs);
- $graph = new graph(600, 300);
+ $graph = new graph(750, 400);
$graph->parameter['title'] = "Rough usage of $course->shortname by $user->firstname $user->lastname";
$graph->x_data = $days;
@@ -59,6 +60,7 @@
$graph->y_data['logs'] = $logs;
$graph->y_format['logs'] = array('colour' => 'blue','bar' => 'fill','legend' =>'actual','bar_size' => 0.4);
$graph->y_label_left = "Hits";
+ $graph->label_size = "6";
$graph->y_order = array('logs');
@@ -69,6 +71,16 @@
break;
+ case "userday.png":
+
+ if (! $date) {
+ error("Must specify a date if you use userday.png format");
+ }
+
+ // XXX still to be done. The day was getting long!
+
+ break;
+
default:
break;
}
View
34 course/user.php
@@ -5,7 +5,7 @@
require_variable($id); // course id
require_variable($user); // user id
- optional_variable($mode, "graph");
+ optional_variable($mode, "outline");
if (! $course = get_record("course", "id", $id)) {
error("Course id is incorrect.");
@@ -24,7 +24,7 @@
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", "$course->fullname",
+ print_header("$course->shortname: Activity Report ($mode)", "$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> ->
@@ -33,11 +33,6 @@
echo "<TABLE CELLPADDING=10 ALIGN=CENTER><TR>";
echo "<TD>Reports: </TD>";
- if ($mode != "graph") {
- echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=graph>Graph</A></TD>";
- } else {
- echo "<TD><U>Graph</U></TD>";
- }
if ($mode != "outline") {
echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=outline>Outline</A></TD>";
} else {
@@ -48,15 +43,34 @@
} else {
echo "<TD><U>Complete</U></TD>";
}
+ if ($mode != "today") {
+ echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=today>Today</A></TD>";
+ } else {
+ echo "<TD><U>Today</U></TD>";
+ }
+ if ($mode != "alllogs") {
+ echo "<TD><A HREF=user.php?id=$course->id&user=$user->id&mode=alllogs>All logs</A></TD>";
+ } else {
+ echo "<TD><U>All logs</U></TD>";
+ }
echo "</TR></TABLE>";
get_all_mods($course->id, $mods, $modtype);
switch ($mode) {
- case "graph" :
- echo "<HR>";
- echo "<CENTER><IMG SRC=\"loggraph.php?id=$course->id&user=$user->id&type=user.png\">";
+ case "today" :
+ echo "<HR><CENTER>";
+ print_log_graph($course, $user->id, "userday.png", usergetmidnight(time()) );
+ echo "</CENTER>";
+ print_log($course, $user->id, usergetmidnight(time()), "ORDER BY l.time DESC");
+ break;
+
+ case "alllogs" :
+ echo "<HR><CENTER>";
+ print_log_graph($course, $user->id, "usercourse.png");
+ echo "</CENTER>";
+ print_log($course, $user->id, 0, "ORDER BY l.time DESC");
break;
case "outline" :
Please sign in to comment.
Something went wrong with that request. Please try again.