2006-03-10 08:07:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('../../../config.php');
|
|
|
|
require_once($CFG->dirroot.'/lib/statslib.php');
|
2006-09-03 14:45:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
|
|
|
|
$adminroot = admin_get_root();
|
|
|
|
|
|
|
|
admin_externalpage_setup('reportcourseoverview', $adminroot);
|
|
|
|
|
|
|
|
admin_externalpage_print_header($adminroot);
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
|
|
|
$time = optional_param('time', 0, PARAM_INT);
|
|
|
|
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
|
|
|
|
2006-09-03 14:45:57 +00:00
|
|
|
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID)); // needed?
|
|
|
|
|
2006-03-10 08:07:08 +00:00
|
|
|
if (empty($CFG->enablestats)) {
|
2006-09-03 14:45:57 +00:00
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'));
|
2006-03-10 08:07:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$course = get_site();
|
|
|
|
stats_check_uptodate($course->id);
|
|
|
|
|
|
|
|
$strreports = get_string('reports');
|
|
|
|
$strcourseoverview = get_string('courseoverview');
|
|
|
|
|
2006-07-19 08:13:25 +00:00
|
|
|
$strnav = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.get_string('administration').'</a> -> <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report.php">'.$strreports.'</a> -> '.$strcourseoverview;
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
|
|
|
|
|
|
|
$tableprefix = $CFG->prefix.'stats_';
|
|
|
|
|
|
|
|
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
|
|
|
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
|
|
|
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
|
|
|
|
|
|
|
if (empty($earliestday)) $earliestday = time();
|
|
|
|
if (empty($earliestweek)) $earliestweek = time();
|
|
|
|
if (empty($earliestmonth)) $earliestmonth = time();
|
|
|
|
|
|
|
|
$now = stats_get_base_daily();
|
|
|
|
$lastweekend = stats_get_base_weekly();
|
|
|
|
$lastmonthend = stats_get_base_monthly();
|
|
|
|
|
|
|
|
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
|
|
|
|
|
|
|
if (empty($timeoptions)) {
|
|
|
|
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '<form action="index.php" method="post">'."\n";
|
|
|
|
|
|
|
|
$table->width = '*';
|
|
|
|
|
|
|
|
$table->align = array('left','left','left','left','left','left');
|
|
|
|
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
|
|
|
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
|
|
|
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
|
|
|
'<input type="submit" value="'.get_string('view').'" />') ;
|
|
|
|
|
|
|
|
print_table($table);
|
|
|
|
echo '</form>';
|
|
|
|
|
|
|
|
if (!empty($report) && !empty($time)) {
|
|
|
|
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
|
|
|
|
|
|
|
|
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
|
|
|
|
." WHERE timeend >= ".$param->timeafter
|
|
|
|
." GROUP BY courseid "
|
|
|
|
.$param->extras
|
|
|
|
." ORDER BY ".$param->orderby
|
|
|
|
." LIMIT ".$numcourses;
|
|
|
|
|
|
|
|
$courses = get_records_sql($sql);
|
|
|
|
|
|
|
|
if (empty($courses)) {
|
2006-07-19 08:13:25 +00:00
|
|
|
error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/index.php');
|
2006-03-10 08:07:08 +00:00
|
|
|
}
|
|
|
|
|
2006-07-19 08:13:25 +00:00
|
|
|
echo '<center><img src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></center>';
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
$table = new object();
|
|
|
|
$table->align = array('left','center','center','center');
|
|
|
|
$table->head = array(get_string('course'),$param->line1);
|
|
|
|
if (!empty($param->line2)) {
|
|
|
|
$table->head[] = $param->line2;
|
|
|
|
}
|
|
|
|
if (!empty($param->line3)) {
|
|
|
|
$table->head[] = $param->line3;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($courses as $c) {
|
|
|
|
$a = array();
|
|
|
|
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
2006-05-29 09:10:33 +00:00
|
|
|
|
|
|
|
$a[] = $c->line1;
|
2006-03-10 08:07:08 +00:00
|
|
|
if (isset($c->line2)) {
|
2006-05-29 09:10:33 +00:00
|
|
|
$a[] = $c->line2;
|
2006-03-10 08:07:08 +00:00
|
|
|
}
|
|
|
|
if (isset($c->line3)) {
|
2006-05-29 09:10:33 +00:00
|
|
|
$a[] = $c->line3;
|
2006-03-10 08:07:08 +00:00
|
|
|
}
|
|
|
|
$table->data[] = $a;
|
|
|
|
}
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
|
2006-09-03 14:45:57 +00:00
|
|
|
admin_externalpage_print_footer($adminroot);
|
2006-03-10 08:07:08 +00:00
|
|
|
|
|
|
|
?>
|