Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/report/stats/index.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require_once('../../config.php');
00027 require_once($CFG->dirroot.'/report/stats/locallib.php');
00028 require_once($CFG->libdir.'/adminlib.php');
00029 
00030 $courseid = optional_param('course', SITEID, PARAM_INT);
00031 $report   = optional_param('report', 0, PARAM_INT);
00032 $time     = optional_param('time', 0, PARAM_INT);
00033 $mode     = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
00034 $userid   = optional_param('userid', 0, PARAM_INT);
00035 $roleid   = 0;
00036 
00037 if ($report > 50) {
00038     $roleid = substr($report,1);
00039     $report = 5;
00040 }
00041 
00042 if ($report == STATS_REPORT_USER_LOGINS) {
00043     $courseid = SITEID; //override
00044 }
00045 
00046 if ($mode == STATS_MODE_RANKED) {
00047     redirect($CFG->wwwroot.'/report/stats/index.php?time='.$time);
00048 }
00049 
00050 if (!$course = $DB->get_record("course", array("id"=>$courseid))) {
00051     print_error("invalidcourseid");
00052 }
00053 
00054 if (!empty($userid)) {
00055     $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
00056 } else {
00057     $user = null;
00058 }
00059 
00060 require_login($course);
00061 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00062 require_capability('report/stats:view', $context);
00063 
00064 $PAGE->set_url(new moodle_url('/report/stats/index.php', array('course' => $course->id,
00065                                                                'report' => $report,
00066                                                                'time'   => $time,
00067                                                                'mode'   => $mode,
00068                                                                'userid' => $userid)));
00069 
00070 add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
00071 stats_check_uptodate($course->id);
00072 
00073 if ($course->id == SITEID) {
00074     admin_externalpage_setup('reportstats', '', null, '', array('pagelayout'=>'report'));
00075     echo $OUTPUT->header();
00076 } else {
00077     $strreports = get_string("reports");
00078     $strstats = get_string('stats');
00079 
00080     $PAGE->set_title("$course->shortname: $strstats");
00081     $PAGE->set_heading($course->fullname);
00082     $PAGE->set_pagelayout('report');
00083     $PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/report/stats/index.php"));
00084     echo $OUTPUT->header();
00085 }
00086 
00087 report_stats_report($course, $report, $mode, $user, $roleid, $time);
00088 
00089 if (empty($CFG->enablestats)) {
00090     if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
00091         redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
00092     } else {
00093         print_error('statsdisable');
00094     }
00095 }
00096 
00097 echo $OUTPUT->footer();
00098 
00099 
 All Data Structures Namespaces Files Functions Variables Enumerations