3 require_once('../../../config.php');
4 require_once($CFG->dirroot
.'/lib/statslib.php');
5 require_once($CFG->dirroot
.'/course/report/stats/lib.php');
7 require_once($CFG->libdir
.'/adminlib.php');
9 admin_externalpage_setup('reportstats');
11 admin_externalpage_print_header();
14 $courseid = optional_param('course', SITEID
, PARAM_INT
);
15 $report = optional_param('report', 0, PARAM_INT
);
16 $time = optional_param('time', 0, PARAM_INT
);
17 $mode = optional_param('mode', STATS_MODE_GENERAL
, PARAM_INT
);
18 $userid = optional_param('userid', 0, PARAM_INT
);
22 $roleid = substr($report,1);
26 if ($report == STATS_REPORT_USER_LOGINS
) {
27 $courseid = SITEID
; //override
30 if ($mode == STATS_MODE_RANKED
) {
31 redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/report/stats/index.php?time='.$time, '', 3);
34 if (!$course = get_record("course","id",$courseid)) {
35 error("That's an invalid course id");
38 if (!empty($userid)) {
39 if (!$user = get_record('user','id',$userid)) {
40 error("That's an invalid user id");
46 if (empty($CFG->enablestats
)) {
47 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
50 require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE
, $course->id
));
52 add_to_log($course->id
, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id
);
54 stats_check_uptodate($course->id
);
57 // $strreports = get_string("reports");
58 // $strstats = get_string('stats');
60 // $menu = report_stats_mode_menu($course, $mode, $time); // add 4th $url parameter if uncommented!
63 // $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
64 // <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
67 // print_header("$course->shortname: $strstats", "$course->fullname",
68 // $crumb, '', '', true, ' ', $menu);
71 require_once($CFG->dirroot
.'/course/report/stats/report.php');
73 admin_externalpage_print_footer();