]> git.mjollnir.org Git - moodle.git/commitdiff
navigation MDL-14632 Added and implemented course report callback function
authorsamhemelryk <samhemelryk>
Mon, 21 Sep 2009 07:22:57 +0000 (07:22 +0000)
committersamhemelryk <samhemelryk>
Mon, 21 Sep 2009 07:22:57 +0000 (07:22 +0000)
course/report.php
course/report/log/index.php
course/report/log/lib.php
course/report/outline/index.php
course/report/outline/lib.php [new file with mode: 0644]
course/report/participation/lib.php [new file with mode: 0644]
course/report/progress/index.php
course/report/progress/lib.php [new file with mode: 0644]
course/report/stats/lib.php
lib/navigationlib.php

index 951ae588e20ffe05133ca2cea0cc8c1331147db6..ad8711bc27d4ff33f224a4e610da827e96bbde41 100644 (file)
@@ -16,7 +16,7 @@
 
     $strreports = get_string('reports');
 
-    $PAGE->navbar->add($strreports);
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/course/report.php', array('id'=>$id)));
     $PAGE->set_title($course->fullname.': '.$strreports);
     $PAGE->set_heading($course->fullname.': '.$strreports);
     echo $OUTPUT->header();
index 1c247337855a84733fefb7c3caa9c831d2e8742d..113db54b4513660fb95984725ca5d394382c7c92 100644 (file)
@@ -33,6 +33,8 @@
     $chooselog   = optional_param('chooselog', 0, PARAM_INT);
     $logformat   = optional_param('logformat', 'showashtml', PARAM_ALPHA);
 
+    $PAGE->set_url(new moodle_url($FULLME));
+
     if ($hostid == $CFG->mnet_localhost_id) {
         if (!$course = $DB->get_record('course', array('id'=>$id))) {
             print_error('That\'s an invalid course id'.$id);
         } else {
             $PAGE->set_title($course->shortname .': '. $strlogs);
             $PAGE->set_heading($course->fullname);
-            $PAGE->navbar->add($strreports, new moodle_url($CFG->wwwroot.'/course/report.php', array('id'=>$course->id)));
-            $PAGE->navbar->add($strlogs);
             echo $OUTPUT->header();
         }
 
index cf79b1ad4fdb842c62e5310494763f0ff4fa6017..a218a600922cd8b74cad0dc94a715aed1cd69cc2 100644 (file)
@@ -1,4 +1,27 @@
-<?php  // $Id$
+<?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
+ *
+ * @package course-report
+ * @copyright  1999 onwards  Martin Dougiamas  http://moodle.com
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 
 function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $selecteddate='today',
                                  $modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
@@ -504,4 +527,23 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
     echo '</form>';
 }
 
-?>
+/**
+ * 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 log_report_extend_navigation($navigation, $course, $context) {
+    global $CFG, $OUTPUT;
+    if (has_capability('coursereport/log:view', $context)) {
+        $url = new moodle_url($CFG->wwwroot.'/course/report/log/index.php', array('id'=>$course->id));
+        $navigation->add(get_string('log:view', 'coursereport_log'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+    }
+    if (has_capability('coursereport/log:viewlive', $context)) {
+        $livelogs = get_string('livelogs');
+        $link = html_link::make('/course/report/log/live.php?id='. $course->id, $livelogs);
+        $link->add_action(new popup_action('click', $link->url, 'livelog', array('height' => 500, 'width' => 800)));
+        $navigation->add($livelogs, $link, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+    }
+}
\ No newline at end of file
index 9b4c6d9207715b31193f5f2a47c5cd77c543aa98..d1d875d828b45c13e512241f1b11cdfa24071cc7 100644 (file)
@@ -11,6 +11,8 @@
         print_error('invalidcourseid');
     }
 
+    $PAGE->set_url(new moodle_url($FULLME));
+
     require_login($course);
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     require_capability('coursereport/outline:view', $context);
diff --git a/course/report/outline/lib.php b/course/report/outline/lib.php
new file mode 100644 (file)
index 0000000..2c6e6c3
--- /dev/null
@@ -0,0 +1,40 @@
+<?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 outline report
+ *
+ * @since 2.0
+ * @package course-report
+ * @copyright 2009 Sam Hemelryk
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * 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 outline_report_extend_navigation($navigation, $course, $context) {
+    global $CFG, $OUTPUT;
+    if (has_capability('coursereport/outline:view', $context)) {
+        $url = new moodle_url($CFG->wwwroot.'/course/report/outline/index.php', array('id'=>$course->id));
+        $navigation->add(get_string( 'activityreport' ), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+    }
+}
\ No newline at end of file
diff --git a/course/report/participation/lib.php b/course/report/participation/lib.php
new file mode 100644 (file)
index 0000000..dd00251
--- /dev/null
@@ -0,0 +1,40 @@
+<?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 participation report
+ *
+ * @since 2.0
+ * @package course-report
+ * @copyright 2009 Sam Hemelryk
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * 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 participation_report_extend_navigation($navigation, $course, $context) {
+    global $CFG, $OUTPUT;
+    if (has_capability('coursereport/participation:view', $context)) {
+        $url = new moodle_url($CFG->wwwroot.'/course/report/participation/index.php', array('id'=>$course->id));
+        $navigation->add(get_string('participationreport'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+    }
+}
\ No newline at end of file
index ae295bea95f0d3061115af89440c48c97a8a4d23..09286a872e4a4a712b800543f074975caffb66ae 100644 (file)
@@ -5,7 +5,8 @@ require_once($CFG->libdir . '/completionlib.php');
 define('COMPLETION_REPORT_PAGE',50);
 
 // Get course
-$course=$DB->get_record('course',array('id'=>required_param('course',PARAM_INT)));
+$id = required_param('course',PARAM_INT);
+$course=$DB->get_record('course',array('id'=>$id));
 if(!$course) {
     print_error('invalidcourseid');
 }
@@ -38,6 +39,18 @@ function csv_quote($value) {
     }
 }
 
+$url = new moodle_url($CFG->wwwroot.'/course/report/progress/index.php', array('course'=>$id));
+if ($sort !== '') {
+    $url->param('sort', $sort);
+}
+if ($format !== '') {
+    $url->param('format', $format);
+}
+if ($start !== '') {
+    $url->param('start', $start);
+}
+$PAGE->set_url($url);
+
 require_login($course);
 
 // Check basic permission
diff --git a/course/report/progress/lib.php b/course/report/progress/lib.php
new file mode 100644 (file)
index 0000000..9eef33d
--- /dev/null
@@ -0,0 +1,40 @@
+<?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 progress report
+ *
+ * @since 2.0
+ * @package course-report
+ * @copyright 2009 Sam Hemelryk
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * 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 progress_report_extend_navigation($navigation, $course, $context) {
+    global $CFG, $OUTPUT;
+    if (has_capability('coursereport/progress:view', $context)) {
+        $url = new moodle_url($CFG->wwwroot.'/course/report/progress/index.php', array('course'=>$course->id));
+        $navigation->add(get_string('completionreport','completion'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+    }
+}
\ No newline at end of file
index 57acc8ae27f6af97df235797415cdf792bb69ed8..b9702d01200ad09dba836ae64b2414f324427540 100644 (file)
@@ -1,59 +1,93 @@
 <?php
-    /**
-    * This file is also required by /admin/reports/stats/index.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);
+    }
     */
-    
-    
-    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 = html_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
-        $select->nothinglabel = false;
-        return $OUTPUT->select($select);
+    $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 = html_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
+    $select->nothinglabel = false;
+    return $OUTPUT->select($select);
+}
 
 
-    function report_stats_timeoptions($mode) {
-        global $CFG, $DB;
-        
-        if ($mode == STATS_MODE_DETAILED) {
-            $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
-            $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
-            $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
-        } else {
-            $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_daily} ORDER BY timeend');
-            $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_weekly} ORDER BY timeend');
-            $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_monthly} ORDER BY timeend');
-        }
+function report_stats_timeoptions($mode) {
+    global $CFG, $DB;
 
+    if ($mode == STATS_MODE_DETAILED) {
+        $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
+        $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
+        $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
+    } else {
+        $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_daily} ORDER BY timeend');
+        $earliestweek = $DB->get_field_sql('SELECT timeend FROM {stats_weekly} ORDER BY timeend');
+        $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_monthly} ORDER BY timeend');
+    }
 
-        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();
+    if (empty($earliestday)) $earliestday = time();
+    if (empty($earliestweek)) $earliestweek = time();
+    if (empty($earliestmonth)) $earliestmonth = time();
 
-        return stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
-    }
+    $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($CFG->wwwroot.'/course/report/stats/index.php', array('id'=>$course->id));
+            $navigation->add(get_string('stats'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+        }
+    }
+}
\ No newline at end of file
index cc0c41cf6d1b5a6606bf748820fb1441d9f01669..251903374ea84f9cf5f846d36ca6caa1d6ebddfb 100644 (file)
@@ -1276,14 +1276,18 @@ class global_navigation extends navigation_node {
 
                 // View course reports
                 if (has_capability('moodle/site:viewreports', $this->context)) { // basic capability for listing of reports
-                    $reportkey = $currentcourse->add(get_string('reports'), self::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/stats'));
+                    $reportkey = $currentcourse->add(get_string('reports'), new moodle_url($CFG->wwwroot.'/course/report.php', array('id'=>$course->id)), self::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/stats'));
                     $reportnav = $currentcourse->get($reportkey);
                     if ($reportnav) {
                         $coursereports = get_plugin_list('coursereport');
                         foreach ($coursereports as $report=>$dir) {
-                            if (has_capability('coursereport/'.$report.':view', $this->context)) {
-                                $url = new moodle_url($CFG->wwwroot.'/course/report/'.$report.'/view/index.php', array('id'=>$course->id));
-                                $reportnav->add(get_string($report.':view', 'coursereport_'.$report), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url('i/report'));
+                            $libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
+                            if (file_exists($libfile)) {
+                                require_once($libfile);
+                                $reportfunction = $report.'_report_extend_navigation';
+                                if (function_exists($report.'_report_extend_navigation')) {
+                                    $reportfunction($reportnav, $course, $this->context);
+                                }
                             }
                         }
                     }