MDL-24328 completion Check criteria are set before showing links to report
authorAaron Barnes <aaronb@catalyst.net.nz>
Wed, 6 Oct 2010 02:23:50 +0000 (02:23 +0000)
committerAaron Barnes <aaronb@catalyst.net.nz>
Wed, 6 Oct 2010 02:23:50 +0000 (02:23 +0000)
course/report/completion/lib.php
course/report/completion/mod.php

index 7a93321..a84f3a2 100644 (file)
@@ -37,9 +37,10 @@ function completion_report_extend_navigation($navigation, $course, $context) {
     global $CFG, $OUTPUT;
 
     if (has_capability('coursereport/completion:view', $context)) {
-        require_once($CFG->libdir.'/completionlib.php');
-
-        $url = new moodle_url('/course/report/completion/index.php', array('course'=>$course->id));
-        $navigation->add(get_string('pluginname','coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
+        $completion = new completion_info($course);
+        if ($completion->is_enabled() && $completion->has_criteria()) {
+            $url = new moodle_url('/course/report/completion/index.php', array('course'=>$course->id));
+            $navigation->add(get_string('pluginname','coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
+        }
     }
 }
index 01c2578..90359a0 100644 (file)
@@ -6,9 +6,9 @@
 
     if (has_capability('coursereport/completion:view', $context)) {
         $completion = new completion_info($course);
-        if ($completion->is_enabled()) {
+        if ($completion->is_enabled() && $completion->has_criteria()) {
             echo '<p>';
-            echo '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?course='.$course->id.'">'.get_string('coursecompletionreport','completion').'</a>';
+            echo '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?coursetest='.$course->id.'">'.get_string('coursecompletionreport','completion').'</a>';
             echo '</p>';
         }
     }