Skip to content

Commit

Permalink
Changes to improve the user activity reports
Browse files Browse the repository at this point in the history
  • Loading branch information
martin committed Jul 27, 2002
1 parent cbc83a3 commit 2b8cef8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
5 changes: 5 additions & 0 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\">";
}

?>
18 changes: 15 additions & 3 deletions course/loggraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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.");
}
}
Expand All @@ -31,7 +32,7 @@

switch ($type) {

case "user.png":
case "usercourse.png":

$timestart = $course->startdate;
$i = 0;
Expand All @@ -51,14 +52,15 @@
$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;

$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');

Expand All @@ -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;
}
Expand Down
34 changes: 24 additions & 10 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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> ->
Expand All @@ -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 {
Expand All @@ -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" :
Expand Down

0 comments on commit 2b8cef8

Please sign in to comment.