From: martin Date: Sat, 27 Jul 2002 09:44:01 +0000 (+0000) Subject: Changes to improve the user activity reports X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2b8cef80381adcaa3432ea82a34aee146a2a4b6a;p=moodle.git Changes to improve the user activity reports --- diff --git a/course/lib.php b/course/lib.php index 88d3061a78..f707420ad6 100644 --- a/course/lib.php +++ b/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 "wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">"; +} + ?> diff --git a/course/loggraph.php b/course/loggraph.php index 2a78bbe340..9e4cc97e00 100644 --- a/course/loggraph.php +++ b/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; } diff --git a/course/user.php b/course/user.php index f639d47a47..10b5f48cdb 100644 --- a/course/user.php +++ b/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", "id\">$course->shortname -> id\">Participants -> id&course=$course->id\">$user->firstname $user->lastname -> @@ -33,11 +33,6 @@ echo ""; echo ""; - if ($mode != "graph") { - echo ""; - } else { - echo ""; - } if ($mode != "outline") { echo ""; } else { @@ -48,15 +43,34 @@ } else { echo ""; } + if ($mode != "today") { + echo ""; + } else { + echo ""; + } + if ($mode != "alllogs") { + echo ""; + } else { + echo ""; + } echo "
Reports: id&user=$user->id&mode=graph>GraphGraphid&user=$user->id&mode=outline>OutlineCompleteid&user=$user->id&mode=today>TodayTodayid&user=$user->id&mode=alllogs>All logsAll logs
"; get_all_mods($course->id, $mods, $modtype); switch ($mode) { - case "graph" : - echo "
"; - echo "
id&user=$user->id&type=user.png\">"; + case "today" : + echo "
"; + print_log_graph($course, $user->id, "userday.png", usergetmidnight(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" :