Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * stats report 19 * 20 * @package report 21 * @subpackage stats 22 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 use core\report_helper; 27 28 require_once('../../config.php'); 29 require_once($CFG->dirroot.'/report/stats/locallib.php'); 30 require_once($CFG->libdir.'/adminlib.php'); 31 32 $courseid = optional_param('course', SITEID, PARAM_INT); 33 $report = optional_param('report', 0, PARAM_INT); 34 $time = optional_param('time', 0, PARAM_INT); 35 $mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT); 36 $userid = optional_param('userid', 0, PARAM_INT); 37 $roleid = 0; 38 39 if ($report > 50) { 40 $roleid = substr($report,1); 41 $report = 5; 42 } 43 44 if ($report == STATS_REPORT_USER_LOGINS) { 45 $courseid = SITEID; //override 46 } 47 48 if ($mode == STATS_MODE_RANKED) { 49 redirect($CFG->wwwroot.'/report/stats/index.php?time='.$time); 50 } 51 52 if (!$course = $DB->get_record("course", array("id"=>$courseid))) { 53 print_error("invalidcourseid"); 54 } 55 56 if (!empty($userid)) { 57 $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); 58 } else { 59 $user = null; 60 } 61 62 require_login($course); 63 $context = context_course::instance($course->id); 64 require_capability('report/stats:view', $context); 65 66 $PAGE->set_url(new moodle_url('/report/stats/index.php', array('course' => $course->id, 67 'report' => $report, 68 'time' => $time, 69 'mode' => $mode, 70 'userid' => $userid))); 71 navigation_node::override_active_url(new moodle_url('/report/stats/index.php', array('course' => $course->id))); 72 73 // Trigger a content view event. 74 $event = \report_stats\event\report_viewed::create(array('context' => $context, 'relateduserid' => $userid, 75 'other' => array('report' => $report, 'time' => $time, 'mode' => $mode))); 76 $event->trigger(); 77 stats_check_uptodate($course->id); 78 79 if ($course->id == SITEID) { 80 admin_externalpage_setup('reportstats', '', null, '', array('pagelayout'=>'report')); 81 echo $OUTPUT->header(); 82 } else { 83 $strreports = get_string("reports"); 84 $strstats = get_string('stats'); 85 86 $PAGE->set_title("$course->shortname: $strstats"); 87 $PAGE->set_heading($course->fullname); 88 $PAGE->set_pagelayout('report'); 89 $PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/report/stats/index.php")); 90 echo $OUTPUT->header(); 91 92 // Print the selected dropdown. 93 $pluginname = get_string('pluginname', 'report_stats'); 94 report_helper::print_report_selector($pluginname); 95 } 96 97 report_stats_report($course, $report, $mode, $user, $roleid, $time); 98 99 if (empty($CFG->enablestats)) { 100 if (has_capability('moodle/site:config', context_system::instance())) { 101 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3); 102 } else { 103 print_error('statsdisable'); 104 } 105 } 106 107 echo $OUTPUT->footer(); 108 109
title
Description
Body
title
Description
Body
title
Description
Body
title
Body