]> git.mjollnir.org Git - moodle.git/commitdiff
New admin stats report. This report module makes use of /course/report/stats/.
authorvyshane <vyshane>
Tue, 6 Jun 2006 05:31:42 +0000 (05:31 +0000)
committervyshane <vyshane>
Tue, 6 Jun 2006 05:31:42 +0000 (05:31 +0000)
Merged from 1.6.

admin/report/stats/index.php [new file with mode: 0644]
admin/report/stats/mod.php [new file with mode: 0644]

diff --git a/admin/report/stats/index.php b/admin/report/stats/index.php
new file mode 100644 (file)
index 0000000..a8cf2eb
--- /dev/null
@@ -0,0 +1,63 @@
+<?php  // $Id$
+
+    require_once('../../../config.php');
+    require_once($CFG->dirroot.'/lib/statslib.php');
+    require_once($CFG->dirroot.'/course/report/stats/lib.php');
+
+    if (empty($CFG->enablestats)) {
+        error("Stats is not enabled.");
+    }
+
+    $courseid = required_param('course', 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);
+
+    if ($report == STATS_REPORT_USER_LOGINS) {
+        $courseid = SITEID; //override
+    }
+
+    if ($mode == STATS_MODE_RANKED) {
+        redirect($CFG->wwwroot.'/'.$CFG->admin.'/report.php?time='.$time);
+    }
+
+    if (!$course = get_record("course","id",$courseid)) {
+        error("That's an invalid course id");
+    }
+
+    if (!empty($userid)) {
+        if (!$user = get_record('user','id',$userid)) {
+            error("That's an invalid user id");
+        }
+    }
+
+    require_login();
+    if (!isteacher($course->id)) {
+        error("You need to be a teacher to use this page");
+    }
+
+    add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id); 
+
+    stats_check_uptodate($course->id);
+    
+    
+    $strreports = get_string("reports");
+    $strstats = get_string('stats');
+
+    $menu = report_stats_mode_menu($course, $mode, $time);
+
+
+    $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
+              <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
+              $strstats";
+
+    print_header("$course->shortname: $strstats", "$course->fullname", 
+                  $crumb, '', '', true, '&nbsp', $menu);
+    
+    
+    require_once($CFG->dirroot.'/course/report/stats/report.php');
+    
+    print_footer();
+
+?>
\ No newline at end of file
diff --git a/admin/report/stats/mod.php b/admin/report/stats/mod.php
new file mode 100644 (file)
index 0000000..c4433a9
--- /dev/null
@@ -0,0 +1,12 @@
+<?php  //$Id$
+
+    if (!defined('MOODLE_INTERNAL')) {
+        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
+    }
+    
+    if (!empty($CFG->enablestats)) {
+        echo '<p style="text-align:center;">';
+        echo '<a href="'.$CFG->wwwroot.'/admin/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
+        echo '</p>';
+    }
+?>
\ No newline at end of file