Merge branch 'MDL-58835_master' of git://github.com/dmonllao/moodle
[moodle.git] / lib / classes / analytics / target / no_teaching.php
index 85e6513..739670e 100644 (file)
@@ -63,6 +63,9 @@ class no_teaching extends \core_analytics\local\target\binary {
      * @return \core_analytics\prediction_action[]
      */
     public function prediction_actions(\core_analytics\prediction $prediction, $includedetailsaction = false) {
+        global $CFG;
+
+        require_once($CFG->dirroot . '/course/lib.php');
 
         $sampledata = $prediction->get_sample_data();
         $course = $sampledata['course'];
@@ -74,7 +77,7 @@ class no_teaching extends \core_analytics\local\target\binary {
         $actions[] = new \core_analytics\prediction_action('viewcourse', $prediction,
             $url, $pix, get_string('view'));
 
-        if (has_any_capability(['moodle/course:viewparticipants', 'moodle/course:enrolreview'], $sampledata['context'])) {
+        if (course_can_view_participants($sampledata['context'])) {
             $url = new \moodle_url('/user/index.php', array('id' => $course->id));
             $pix = new \pix_icon('i/cohort', get_string('participants'));
             $actions[] = new \core_analytics\prediction_action('viewparticipants', $prediction,