3 require_once('../../../config.php');
4 require_once($CFG->dirroot
.'/lib/statslib.php');
5 require_once($CFG->dirroot
.'/course/report/stats/lib.php');
7 if (empty($CFG->enablestats
)) {
8 error("Stats is not enabled.");
11 $courseid = required_param('course', PARAM_INT
);
12 $report = optional_param('report', 0, PARAM_INT
);
13 $time = optional_param('time', 0, PARAM_INT
);
14 $mode = optional_param('mode', STATS_MODE_GENERAL
, PARAM_INT
);
15 $userid = optional_param('userid', 0, PARAM_INT
);
19 $roleid = substr($report,1);
23 if ($report == STATS_REPORT_USER_LOGINS
) {
24 $courseid = SITEID
; //override
27 if ($mode == STATS_MODE_RANKED
) {
28 redirect($CFG->wwwroot
.'/'.$CFG->admin
.'/report/stats/index.php?time='.$time);
31 if (!$course = get_record("course","id",$courseid)) {
32 error("That's an invalid course id");
35 if (!empty($userid)) {
36 if (!$user = get_record('user','id',$userid)) {
37 error("That's an invalid user id");
41 require_login($course);
42 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
44 require_capability('moodle/site:viewreports', $context);
46 add_to_log($course->id
, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id
);
47 stats_check_uptodate($course->id
);
50 $strreports = get_string("reports");
51 $strstats = get_string('stats');
53 $menu = report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php");
56 $navlinks[] = array('name' => $strreports, 'link' => "../../report.php?id=$course->id", 'type' => 'misc');
57 $navlinks[] = array('name' => $strstats, 'link' => null, 'type' => 'misc');
58 $navigation = build_navigation($navlinks);
60 print_header("$course->shortname: $strstats", $course->fullname
, $navigation, '', '', true, ' ', $menu);
63 require_once($CFG->dirroot
.'/course/report/stats/report.php');