MDL-29030 migration and cleanup of stats report
AMOS BEGIN MOV [pluginpagetype,coursereport_stats],[pluginpagetype,report_stats] MOV [stats:view,coursereport_stats],[stats:view,report_stats] AMOS END
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = 0;
|
||||
|
||||
if ($report > 50) {
|
||||
$roleid = substr($report,1);
|
||||
$report = 5;
|
||||
}
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/course/report/stats/index.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record("course", array("id"=>$courseid))) {
|
||||
print_error("invalidcourseid");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error("nousers");
|
||||
}
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('coursereport/stats:view', $context);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/course/report/stats/index.php', array('course' => $course->id,
|
||||
'report' => $report,
|
||||
'time' => $time,
|
||||
'mode' => $mode,
|
||||
'userid' => $userid)));
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
admin_externalpage_setup('reportstats');
|
||||
echo $OUTPUT->header();
|
||||
} else {
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$PAGE->set_title("$course->shortname: $strstats");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_pagelayout('report');
|
||||
$PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php"));
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
require($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
} else {
|
||||
print_error('statsdisable');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains functions used by the log reports
|
||||
*
|
||||
* This file is also required by /admin/reports/stats/index.php.
|
||||
*
|
||||
* @package course-report
|
||||
* @copyright 1999 onwards Martin Dougiamas http://moodle.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
function report_stats_mode_menu($course, $mode, $time, $url) {
|
||||
global $CFG, $OUTPUT;
|
||||
/*
|
||||
$reportoptions = stats_get_report_options($course->id, $mode);
|
||||
$timeoptions = report_stats_timeoptions($mode);
|
||||
if (empty($timeoptions)) {
|
||||
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
*/
|
||||
|
||||
$options = array();
|
||||
$options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
|
||||
$options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
|
||||
if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$options[STATS_MODE_RANKED] = get_string('reports');
|
||||
}
|
||||
$popupurl = $url."?course=$course->id&time=$time";
|
||||
$select = new single_select(new moodle_url($popupurl), 'mode', $options, $mode, null);
|
||||
$select->formid = 'switchmode';
|
||||
return $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
|
||||
function report_stats_timeoptions($mode) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_monthly}');
|
||||
} else {
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
|
||||
}
|
||||
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
return stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the navigation with the report items
|
||||
*
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param stdClass $course The course to object for the report
|
||||
* @param stdClass $context The context of the course
|
||||
*/
|
||||
function stats_report_extend_navigation($navigation, $course, $context) {
|
||||
global $CFG, $OUTPUT;
|
||||
if (has_capability('coursereport/stats:view', $context)) {
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$url = new moodle_url('/course/report/stats/index.php', array('course'=>$course->id));
|
||||
$navigation->add(get_string('stats'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of page types
|
||||
* @param string $pagetype current page type
|
||||
* @param stdClass $parentcontext Block's parent context
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function stats_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$array = array(
|
||||
'*' => get_string('page-x', 'pagetype'),
|
||||
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
|
||||
'course-report-stats-index' => get_string('pluginpagetype', 'coursereport_stats')
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (has_capability('coursereport/stats:view', $context)) {
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p>';
|
||||
echo '<a href="'.$CFG->wwwroot.'/course/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
echo '</p>';
|
||||
} else {
|
||||
echo '<p>';
|
||||
echo get_string('statsoff');
|
||||
echo '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$plugin->version = 2010090501;
|
||||
$plugin->requires = 2010090501;
|
||||
|
||||
|
||||
+1
-1
@@ -304,7 +304,7 @@ class plugin_manager {
|
||||
),
|
||||
|
||||
'coursereport' => array(
|
||||
'stats'
|
||||
//deprecated!
|
||||
),
|
||||
|
||||
'datafield' => array(
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'coursereport/stats:view' => array(
|
||||
'report/stats:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -35,7 +35,7 @@ $capabilities = array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
'clonepermissionsfrom' => 'coursereport/stats:view',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Post installation and migration code.
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_report_stats_install() {
|
||||
// this is a hack which is needed for cleanup of original coursereport_stats stuff
|
||||
unset_all_config_for_plugin('coursereport_stats');
|
||||
capabilities_cleanup('coursereport_stats');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,12 +17,13 @@
|
||||
/**
|
||||
* This file is part of the User section Moodle
|
||||
*
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package course
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../../config.php');
|
||||
require('../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/lib/graphlib.php');
|
||||
|
||||
@@ -34,7 +34,7 @@ $mode = required_param('mode', PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = optional_param('roleid',0,PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/course/report/stats/graph.php', array('course'=>$courseid, 'report'=>$report, 'time'=>$time, 'mode'=>$mode));
|
||||
$url = new moodle_url('/report/stats/graph.php', array('course'=>$courseid, 'report'=>$report, 'time'=>$time, 'mode'=>$mode));
|
||||
if ($userid !== 0) {
|
||||
$url->param('userid', $userid);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (!$course->showreports or $USER->id != $userid) {
|
||||
require_capability('coursereport/stats:view', $context);
|
||||
require_capability('report/stats:view', $context);
|
||||
}
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* stats report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/report/stats/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = 0;
|
||||
|
||||
if ($report > 50) {
|
||||
$roleid = substr($report,1);
|
||||
$report = 5;
|
||||
}
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/report/stats/index.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record("course", array("id"=>$courseid))) {
|
||||
print_error("invalidcourseid");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('report/stats:view', $context);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/report/stats/index.php', array('course' => $course->id,
|
||||
'report' => $report,
|
||||
'time' => $time,
|
||||
'mode' => $mode,
|
||||
'userid' => $userid)));
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
admin_externalpage_setup('reportstats');
|
||||
echo $OUTPUT->header();
|
||||
} else {
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$PAGE->set_title("$course->shortname: $strstats");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_pagelayout('report');
|
||||
$PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/report/stats/index.php"));
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
report_stats_report($course, $report, $mode, $user, $roleid, $time);
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
} else {
|
||||
print_error('statsdisable');
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'report_stats'
|
||||
* Strings
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 2011 Petr Skoda (http://skodak.org)
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Statistics';
|
||||
$string['pluginpagetype'] = 'Statistics course report';
|
||||
$string['stats:view'] = 'View course statistics report';
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains functions used by the log reports
|
||||
*
|
||||
* This file is also required by /admin/reports/stats/index.php.
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* This function extends the navigation with the report items
|
||||
*
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param stdClass $course The course to object for the report
|
||||
* @param stdClass $context The context of the course
|
||||
*/
|
||||
function report_stats_extend_navigation_course($navigation, $course, $context) {
|
||||
global $CFG, $OUTPUT;
|
||||
if (has_capability('report/stats:view', $context)) {
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$url = new moodle_url('/report/stats/index.php', array('course'=>$course->id));
|
||||
$navigation->add(get_string('pluginname', 'report_stats'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of page types
|
||||
* @param string $pagetype current page type
|
||||
* @param stdClass $parentcontext Block's parent context
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
* @return array
|
||||
*/
|
||||
function report_stats_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$array = array(
|
||||
'*' => get_string('page-x', 'pagetype'),
|
||||
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
|
||||
'course-report-stats-index' => get_string('pluginpagetype', 'report_stats')
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
@@ -1,7 +1,87 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
/**
|
||||
* Reports implementation
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once(dirname(__FILE__).'/lib.php');
|
||||
|
||||
|
||||
function report_stats_mode_menu($course, $mode, $time, $url) {
|
||||
global $CFG, $OUTPUT;
|
||||
/*
|
||||
$reportoptions = stats_get_report_options($course->id, $mode);
|
||||
$timeoptions = report_stats_timeoptions($mode);
|
||||
if (empty($timeoptions)) {
|
||||
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
*/
|
||||
|
||||
$options = array();
|
||||
$options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
|
||||
$options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
|
||||
if (has_capability('report/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$options[STATS_MODE_RANKED] = get_string('reports');
|
||||
}
|
||||
$popupurl = $url."?course=$course->id&time=$time";
|
||||
$select = new single_select(new moodle_url($popupurl), 'mode', $options, $mode, null);
|
||||
$select->formid = 'switchmode';
|
||||
return $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
function report_stats_timeoptions($mode) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_monthly}');
|
||||
} else {
|
||||
$earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
|
||||
$earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
|
||||
}
|
||||
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
return stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
}
|
||||
|
||||
function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
if ($user) {
|
||||
$userid = $user->id;
|
||||
} else {
|
||||
$userid = 0;
|
||||
}
|
||||
|
||||
$courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname');
|
||||
@@ -10,7 +90,7 @@
|
||||
foreach ($courses as $c) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $c->id);
|
||||
|
||||
if (has_capability('coursereport/stats:view', $context)) {
|
||||
if (has_capability('report/stats:view', $context)) {
|
||||
$courseoptions[$c->id] = format_string($c->shortname, true, array('context' => $context));
|
||||
}
|
||||
}
|
||||
@@ -21,6 +101,7 @@
|
||||
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
$users = array();
|
||||
$table = new html_table();
|
||||
$table->width = 'auto';
|
||||
|
||||
@@ -116,9 +197,9 @@
|
||||
echo "(".get_string("gdneed").")";
|
||||
} else {
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
echo '<div class="graph"><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&userid='.$userid.'" alt="'.get_string('statisticsgraph').'" /></div';
|
||||
echo '<div class="graph"><img src="'.$CFG->wwwroot.'/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&userid='.$userid.'" alt="'.get_string('statisticsgraph').'" /></div';
|
||||
} else {
|
||||
echo '<div class="graph"><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&roleid='.$roleid.'" alt="'.get_string('statisticsgraph').'" /></div>';
|
||||
echo '<div class="graph"><img src="'.$CFG->wwwroot.'/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&roleid='.$roleid.'" alt="'.get_string('statisticsgraph').'" /></div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,15 +219,17 @@
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
}
|
||||
if (empty($param->crosstab)) {
|
||||
if (!file_exists($CFG->dirroot.'/report/log/index.php')) {
|
||||
// bad luck, we can not link other report
|
||||
} else if (empty($param->crosstab)) {
|
||||
foreach ($stats as $stat) {
|
||||
$a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1);
|
||||
if (isset($stat->line2)) {
|
||||
$a[] = $stat->line2;
|
||||
}
|
||||
if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) {
|
||||
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?id='.
|
||||
if (has_capability('report/log:view', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/report/log/index.php?id='.
|
||||
$course->id.'&chooselog=1&showusers=1&showcourses=1&user='
|
||||
.$userid.'&date='.usergetmidnight($stat->timeend-(60*60*24)).'">'
|
||||
.get_string('course').' ' .get_string('logs').'</a> ';
|
||||
@@ -202,8 +285,8 @@
|
||||
krsort($rolesdata);
|
||||
$row = array_merge(array($times[$time]),$rolesdata);
|
||||
if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) {
|
||||
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$row[] = '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?id='
|
||||
if (has_capability('report/log:view', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$row[] = '<a href="'.$CFG->wwwroot.'/report/log/index.php?id='
|
||||
.$course->id.'&chooselog=1&showusers=1&showcourses=1&user='.$userid
|
||||
.'&date='.usergetmidnight($time-(60*60*24)).'">'
|
||||
.get_string('course').' ' .get_string('logs').'</a> ';
|
||||
@@ -217,12 +300,11 @@
|
||||
$table->head = array_merge($table->head,$roles);
|
||||
}
|
||||
$table->head[] = get_string('logs');
|
||||
if (!empty($lastrecord)) {
|
||||
$lastrecord[] = $lastlink;
|
||||
$table->data[] = $lastrecord;
|
||||
}
|
||||
//if (!empty($lastrecord)) {
|
||||
//$lastrecord[] = $lastlink;
|
||||
//$table->data[] = $lastrecord;
|
||||
//}
|
||||
echo html_writer::table($table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +1,32 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Version info
|
||||
*
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
// just a link to course report
|
||||
$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/course/report/stats/index.php", 'coursereport/stats:view'));
|
||||
$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('pluginname', 'report_stats'), "$CFG->wwwroot/report/stats/index.php", 'report/stats:view'));
|
||||
|
||||
// no report settings
|
||||
$settings = null;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -16,13 +15,16 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'coursereport_stats', language 'en', branch 'MOODLE_20_STABLE'
|
||||
* Version info
|
||||
*
|
||||
* @package coursereport_stats
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package report
|
||||
* @subpackage stats
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Course statistics';
|
||||
$string['pluginpagetype'] = 'Statistics course report';
|
||||
$string['stats:view'] = 'View course statistics report';
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2011110200; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011102700.01; // Requires this Moodle version
|
||||
$plugin->component = 'report_stats'; // Full name of the plugin (used for diagnostics)
|
||||
Reference in New Issue
Block a user