MDL-27757 lib/completionlib.php: Load "enablecompletion" property if required
authorAaron Barnes <aaronb@catalyst.net.nz>
Fri, 10 Jun 2011 01:53:58 +0000 (13:53 +1200)
committerAaron Barnes <aaronb@catalyst.net.nz>
Fri, 10 Jun 2011 01:58:41 +0000 (13:58 +1200)
lib/completionlib.php

index 7f79c95..4c8467b 100644 (file)
@@ -185,13 +185,18 @@ class completion_info {
      *   for a course-module.
      */
     public function is_enabled($cm=null) {
-        global $CFG;
+        global $CFG, $DB;
 
         // First check global completion
         if (!isset($CFG->enablecompletion) || $CFG->enablecompletion == COMPLETION_DISABLED) {
             return COMPLETION_DISABLED;
         }
 
+        // Load data if we do not have enough
+        if (!isset($this->course->enablecompletion)) {
+            $this->course->enablecompletion = $DB->get_field('course', 'enablecompletion', array('id' => $this->course->id));
+        }
+
         // Check course completion
         if ($this->course->enablecompletion == COMPLETION_DISABLED) {
             return COMPLETION_DISABLED;