mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Fixed up the graphs (one for userday and they are also now correct for timezones)
This commit is contained in:
parent
cbd1170e91
commit
394933864c
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user