2006-03-10 08:07:08 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
|
|
|
require_once('../../../config.php');
|
|
|
|
require_once($CFG->dirroot.'/lib/statslib.php');
|
|
|
|
require_once($CFG->dirroot.'/lib/graphlib.php');
|
|
|
|
|
|
|
|
$report = required_param('report', PARAM_INT);
|
|
|
|
$time = required_param('time', PARAM_INT);
|
|
|
|
$numcourses = required_param('numcourses', PARAM_INT);
|
|
|
|
|
|
|
|
require_login();
|
|
|
|
|
2007-08-03 03:30:23 +00:00
|
|
|
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2007-08-03 03:30:23 +00:00
|
|
|
stats_check_uptodate();
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
|
|
|
|
2006-09-24 07:13:33 +00:00
|
|
|
if (!empty($param->sql)) {
|
2006-10-24 22:00:29 +00:00
|
|
|
$sql = $param->sql;
|
2006-09-24 07:13:33 +00:00
|
|
|
} else {
|
|
|
|
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
2008-02-16 18:33:50 +00:00
|
|
|
." WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0"
|
2006-09-24 07:13:33 +00:00
|
|
|
." GROUP BY courseid "
|
|
|
|
.$param->extras
|
2006-10-24 22:00:29 +00:00
|
|
|
." ORDER BY ".$param->orderby;
|
2006-09-24 07:13:33 +00:00
|
|
|
}
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2006-10-24 22:00:29 +00:00
|
|
|
$courses = get_records_sql($sql, 0, $numcourses);
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2006-03-10 08:07:08 +00:00
|
|
|
if (empty($courses)) {
|
2006-07-19 08:13:25 +00:00
|
|
|
error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
|
2006-03-10 08:07:08 +00:00
|
|
|
}
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
$graph = new graph(750,400);
|
|
|
|
|
|
|
|
$graph->parameter['legend'] = 'outside-right';
|
|
|
|
$graph->parameter['legend_size'] = 10;
|
|
|
|
$graph->parameter['x_axis_angle'] = 90;
|
|
|
|
$graph->parameter['title'] = false; // moodle will do a nicer job.
|
2006-11-24 18:31:41 +00:00
|
|
|
$graph->y_tick_labels = null;
|
|
|
|
$graph->offset_relation = null;
|
2006-03-10 08:07:08 +00:00
|
|
|
if ($report != STATS_REPORT_ACTIVE_COURSES) {
|
|
|
|
$graph->parameter['y_decimal_left'] = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($courses as $c) {
|
|
|
|
$graph->x_data[] = get_field('course','shortname','id',$c->courseid);
|
|
|
|
$graph->y_data['bar1'][] = $c->{$param->graphline};
|
|
|
|
}
|
|
|
|
$graph->y_order = array('bar1');
|
|
|
|
$graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
|
|
|
|
|
|
|
|
$graph->draw_stack();
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2006-03-10 08:07:08 +00:00
|
|
|
?>
|