MDL-60596 analytics: Check cm completion if available
authorDavid Monllao <davidm@moodle.com>
Fri, 20 Oct 2017 09:16:53 +0000 (11:16 +0200)
committerDavid Monllao <davidm@moodle.com>
Fri, 3 Nov 2017 11:44:21 +0000 (12:44 +0100)
Previous code was restricted to course modules origin.

course/classes/analytics/indicator/completion_enabled.php

index f2598e0..87d0919 100644 (file)
@@ -69,10 +69,8 @@ class completion_enabled extends \core_analytics\local\indicator\binary {
 
         $course = $this->retrieve('course', $sampleid);
 
-        $cm = false;
-        if ($sampleorigin === 'course_modules') {
-            $cm = $this->retrieve('course_modules', $sampleid);
-        }
+        // It may not be available, but if it is the indicator checks if completion is enabled for the cm.
+        $cm = $this->retrieve('course_modules', $sampleid);
 
         $completion = new \completion_info($course);