]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17372 course reports: Added full plugin support for course reports
authorskodak <skodak>
Thu, 27 Nov 2008 20:30:14 +0000 (20:30 +0000)
committerskodak <skodak>
Thu, 27 Nov 2008 20:30:14 +0000 (20:30 +0000)
course/report.php
course/report/log/mod.php
course/report/outline/mod.php
course/report/participation/mod.php
course/report/progress/mod.php
course/report/stats/mod.php
lib/accesslib.php
lib/adminlib.php

index 9cf29228a930362959efcf1f16ab959c45a2ef0c..21e3632d27150c2391bde6afb86c848b2be49f21 100644 (file)
@@ -9,9 +9,9 @@
         print_error("That's an invalid course id");
     }
 
-    require_login($course->id);
+    require_login($course);
 
-    $context=get_context_instance(CONTEXT_COURSE, $course->id);
+    $context = get_context_instance(CONTEXT_COURSE, $course->id);
     require_capability('moodle/site:viewreports', $context);
 
     $strreports = get_string('reports');
     foreach ($directories as $directory) {
         $pluginfile = $CFG->dirroot.'/course/report/'.$directory.'/mod.php';
         if (file_exists($pluginfile)) {
-            echo '<div class="plugin">';
-            //echo $pluginfile;
-            include_once($pluginfile);  // Fragment for listing
-            echo '</div>';
+            ob_start();
+            include($pluginfile);  // Fragment for listing
+            $html = ob_get_contents();
+            ob_end_clean();
+            // add div only if plugin accessible
+            if ($html !== '') {
+                echo '<div class="plugin">';
+                echo $html;
+                echo '</div>';
+            }
         }
     }
 
index 6673a1c307f98a774cc61687b3f2d9372afe367b..e9470d8decce0fc0bb269440040d7468f38a7cab 100644 (file)
@@ -7,13 +7,14 @@
     require_once($CFG->dirroot.'/course/lib.php');
     require_once($CFG->dirroot.'/course/report/log/lib.php');
 
+    if (has_capability('moodle/site:viewreports', $context)) {
+        print_heading(get_string('chooselogs') .':');
 
-    print_heading(get_string('chooselogs') .':');
+        print_log_selector_form($course);
 
-    print_log_selector_form($course); 
-
-    print_heading(get_string('chooselivelogs') .':');
-    echo '<p>';
-    link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800);
-    echo '</p>';
+        print_heading(get_string('chooselivelogs') .':');
+        echo '<p>';
+        link_to_popup_window('/course/report/log/live.php?id='. $course->id,'livelog', get_string('livelogs'), 500, 800);
+        echo '</p>';
+    }
 ?>
\ No newline at end of file
index 4dfc569fcf494a803ecfe096f221f1f8f6dd812b..042e57b0f045293e3d5411a71b9de04b8d962cf5 100644 (file)
@@ -4,9 +4,11 @@
         die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
     }
 
-    echo '<p>';
-    $activityreport = get_string( 'activityreport' );
-    echo "<a href=\"{$CFG->wwwroot}/course/report/outline/index.php?id={$course->id}\">";
-    echo "$activityreport</a>\n";
-    echo '</p>';
+    if (has_capability('moodle/site:viewreports', $context)) {
+        echo '<p>';
+        $activityreport = get_string( 'activityreport' );
+        echo "<a href=\"{$CFG->wwwroot}/course/report/outline/index.php?id={$course->id}\">";
+        echo "$activityreport</a>\n";
+        echo '</p>';
+    }
 ?>
\ No newline at end of file
index 22146808d04ac75c10b85a63136e559e8e2f0e65..77c4472646d56334a01bb194034aed119334bb0c 100644 (file)
@@ -4,10 +4,11 @@
         die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
     }
 
-    echo '<p>';
-    $participationreport = get_string('participationreport');
-    echo "<a href=\"{$CFG->wwwroot}/course/report/participation/index.php?id={$course->id}\">";
-    echo "$participationreport</a>\n";
-    echo '</p>';
-
+    if (has_capability('moodle/site:viewreports', $context)) {
+        echo '<p>';
+        $participationreport = get_string('participationreport');
+        echo "<a href=\"{$CFG->wwwroot}/course/report/participation/index.php?id={$course->id}\">";
+        echo "$participationreport</a>\n";
+        echo '</p>';
+    }
 ?>
index 94231009c6c5c99e343f5cf4d7fa93217ebedb9a..5ce896e280d917cdabeee080a4b8e537c6e94109 100644 (file)
@@ -4,10 +4,12 @@
         die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
     }
 
-    $completion=new completion_info($course);
-    if ($completion->is_enabled() && has_capability('moodle/course:viewprogress',$context)) {
-        echo '<p>';
-        echo '<a href="'.$CFG->wwwroot.'/course/report/progress/?course='.$course->id.'">'.get_string('completionreport','completion').'</a>';
-        echo '</p>';
-    } 
+    if (has_capability('moodle/site:viewreports', $context)) {
+        $completion = new completion_info($course);
+        if ($completion->is_enabled() && has_capability('moodle/course:viewprogress', $context)) {
+            echo '<p>';
+            echo '<a href="'.$CFG->wwwroot.'/course/report/progress/?course='.$course->id.'">'.get_string('completionreport','completion').'</a>';
+            echo '</p>';
+        }
+    }
 ?>
index 1f305d42c464af64ce34e0dec44b75a7a1fc4ba0..a57ee59b8931d49c6b503dc60b99186e000338a2 100644 (file)
@@ -3,14 +3,16 @@
     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>';
-        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>';
+
+    if (has_capability('moodle/site:viewreports', $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>';
+        }
     }
 ?>
index 9560af3facc6f4509931130d266da9037b179dd7..354361a5964f44b7325cda35b7921a50e5c2c351 100755 (executable)
@@ -3061,6 +3061,10 @@ function load_capability_def($component) {
             $defpath = $CFG->dirroot.'/mod/quiz/report/'.$compparts[1].'/db/access.php';
             $varprefix = $compparts[0].'_'.$compparts[1];
 
+        } else if ($compparts[0] == 'coursereport') {
+            $defpath = $CFG->dirroot.'/course/report/'.$compparts[1].'/db/access.php';
+            $varprefix = $compparts[0].'_'.$compparts[1];
+
         } else {
             $defpath = $CFG->dirroot.'/'.$component.'/db/access.php';
             $varprefix = str_replace('/', '_', $component);
@@ -3928,6 +3932,10 @@ function get_capability_string($capabilityname) {
             $string = get_string($stringname, 'gradereport_'.$componentname);
         break;
 
+        case 'coursereport':
+            $string = get_string($stringname, 'coursereport_'.$componentname);
+        break;
+
         case 'quizreport':
             $string = get_string($stringname, 'quiz_'.$componentname);
         break;
@@ -3980,6 +3988,8 @@ function get_component_string($component, $contextlevel) {
                 || preg_match('|^gradeexport/|', $component)
                 || preg_match('|^gradereport/|', $component)) {
                 $string = get_string('gradebook', 'admin');
+            } else if (preg_match('|^coursereport/|', $component)) {
+                $string = get_string('reports');
             } else {
                 $string = get_string('course');
             }
@@ -5557,13 +5567,20 @@ function component_level_changed($cap, $comp, $contextlevel) {
         $compsa = explode('/', $cap->component);
         $compsb = explode('/', $comp);
 
-
+        // list of system reports
+        if (($compsa[0] == 'report') && ($compsb[0] == 'report')) {
+            return false;
+        }
 
         // we are in gradebook, still
         if (($compsa[0] == 'gradeexport' || $compsa[0] == 'gradeimport' || $compsa[0] == 'gradereport') &&
             ($compsb[0] == 'gradeexport' || $compsb[0] == 'gradeimport' || $compsb[0] == 'gradereport')) {
             return false;
         }
+
+        if (($compsa[0] == 'coursereport') && ($compsb[0] == 'coursereport')) {
+            return false;
+        }
     }
 
     return ($cap->component != $comp || $cap->contextlevel != $contextlevel);
index 9cfb22f143267842da1b77392912722408146ea3..027452dc19f4936bf89031dbccdcdd923f46881f 100644 (file)
@@ -414,6 +414,9 @@ function upgrade_db($version, $release) {
 /// Check all message output plugins and upgrade if necessary
     upgrade_plugins('message','message/output',$return_url);
 
+/// Check all course report plugins and upgrade if necessary
+    upgrade_plugins('coursereport', 'course/report', $return_url);
+
 /// Check all admin report plugins and upgrade if necessary
     upgrade_plugins('report', $CFG->admin.'/report', $return_url);