. /** * Course overview report * * @package report * @subpackage courseoverview * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once('../../config.php'); require_once($CFG->dirroot.'/lib/statslib.php'); require_once($CFG->libdir.'/adminlib.php'); $report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT); $time = optional_param('time', 0, PARAM_INT); $numcourses = optional_param('numcourses', 20, PARAM_INT); if (empty($CFG->enablestats)) { if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3); } else { print_error('statsdisable'); } } admin_externalpage_setup('reportcourseoverview', '', null, '', array('pagelayout'=>'report')); echo $OUTPUT->header(); $course = get_site(); stats_check_uptodate($course->id); $strreports = get_string('reports'); $strcourseoverview = get_string('courseoverview'); $reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED); $earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}'); $earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}'); $earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}'); 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)) { print_error('nostatstodisplay', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id); } echo '
'; echo $OUTPUT->heading($reportoptions[$report]); if (!empty($report) && !empty($time)) { $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED); if (!empty($param->sql)) { $sql = $param->sql; } else { $sql = "SELECT courseid,".$param->fields." FROM {".'stats_'.$param->table."} WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0 GROUP BY courseid $param->extras ORDER BY $param->orderby"; } $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses); if (empty($courses)) { echo $OUTPUT->notification(get_string('statsnodata')); echo ''; } else { if (empty($CFG->gdversion)) { echo '