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");
42 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
44 if (!has_capability('moodle/site:viewreports', $context)) {
45 error('You need do not have the required permission to view reports for this course');
48 add_to_log($course->id
, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id
);
49 stats_check_uptodate($course->id
);
52 $strreports = get_string("reports");
53 $strstats = get_string('stats');
55 $menu = report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php");
57 $crumb = "<a href=\"../../view.php?id=$course->id\">" . format_string($course->shortname
) . "</a> ->
58 <a href=\"../../report.php?id=$course->id\">$strreports</a> ->
61 print_header("$course->shortname: $strstats", $course->fullname
,
62 $crumb, '', '', true, ' ', $menu);
65 require_once($CFG->dirroot
.'/course/report/stats/report.php');