Permalink
Browse files

Fixed up the graphs (one for userday and they are also now correct fo…

…r timezones)
  • Loading branch information...
1 parent cbd1170 commit 394933864cb60f1d3276e67e8760083c6b0a8f8b martin committed Jul 27, 2002
Showing with 39 additions and 8 deletions.
  1. +38 −7 course/loggraph.php
  2. +1 −1 course/user.php
View
45 course/loggraph.php
@@ -34,7 +34,7 @@
case "usercourse.png":
- $timestart = $course->startdate;
+ $timestart = usergetmidnight($course->startdate);
$i = 0;
while ($timestart < $timenow) {
$timefinish = $timestart + (3600 * 24);
@@ -44,7 +44,7 @@
$logs[$i] = 0;
}
$logs[$i] = $logcount->count;
- $days[$i] = date("j M", $timestart);
+ $days[$i] = userdate($timestart, "%a %e %b");
$i++;
$timestart = $timefinish;
}
@@ -53,12 +53,12 @@
$graph = new graph(750, 400);
- $graph->parameter['title'] = "Rough usage of $course->shortname by $user->firstname $user->lastname";
+ $graph->parameter['title'] = "Hits on $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_format['logs'] = array('colour' => 'blue','bar' => 'fill','legend' =>'actual','bar_size' => 0.9);
$graph->y_label_left = "Hits";
$graph->label_size = "6";
@@ -73,11 +73,42 @@
case "userday.png":
- if (! $date) {
- error("Must specify a date if you use userday.png format");
+ if ($date) {
+ $timestart = usergetmidnight($date);
+ } else {
+ $timestart = usergetmidnight(time());
+ }
+ while ($timestart < $timenow) {
+ $timefinish = $timestart + 3600;
+ if (! $logcount = get_record_sql("SELECT COUNT(*) as count FROM log
+ WHERE user = '$user->id' AND course = '$course->id'
+ AND `time` > '$timestart' AND `time` < '$timefinish'")) {
+ $logs[$i] = 0;
+ }
+ $logs[$i] = $logcount->count;
+ $hours[$i] = userdate($timestart, "%I %p");
+ $i++;
+ $timestart = $timefinish;
}
- // XXX still to be done. The day was getting long!
+ $maxlogs = max($logs);
+
+ $graph = new graph(750, 400);
+ $graph->parameter['title'] = "Today's hits on $course->shortname by $user->firstname $user->lastname";
+
+ $graph->x_data = $hours;
+
+ $graph->y_data['logs'] = $logs;
+ $graph->y_format['logs'] = array('colour' => 'blue','bar' => 'fill','legend' =>'actual','bar_size' => 0.9);
+ $graph->y_label_left = "Hits";
+ $graph->label_size = "6";
+
+ $graph->y_order = array('logs');
+
+
+ $graph->parameter['shadow'] = 'none';
+
+ $graph->draw_stack();
break;
View
2 course/user.php
@@ -61,7 +61,7 @@
switch ($mode) {
case "today" :
echo "<HR><CENTER>";
- print_log_graph($course, $user->id, "userday.png", usergetmidnight(time()) );
+ print_log_graph($course, $user->id, "userday.png", time() );
echo "</CENTER>";
print_log($course, $user->id, usergetmidnight(time()), "ORDER BY l.time DESC");
break;

0 comments on commit 3949338

Please sign in to comment.