MDL-57791 analytics: Remove reference to removed config var
authorDavid Monllao <davidm@moodle.com>
Wed, 28 Jun 2017 07:17:56 +0000 (09:17 +0200)
committerDavid Monllao <davidm@moodle.com>
Mon, 24 Jul 2017 06:37:02 +0000 (08:37 +0200)
course/classes/analytics/indicator/no_teacher.php

index d240a96..78e3597 100644 (file)
@@ -35,6 +35,13 @@ defined('MOODLE_INTERNAL') || die();
  */
 class no_teacher extends \core_analytics\local\indicator\binary {
 
+    /**
+     * Teacher role ids.
+     *
+     * @var array|null
+     */
+    protected $teacherroleids = null;
+
     /**
      * get_name
      *
@@ -68,9 +75,11 @@ class no_teacher extends \core_analytics\local\indicator\binary {
 
         $context = $this->retrieve('context', $sampleid);
 
-        $teacherroles = get_config('analytics', 'teacherroles');
-        $teacherroleids = explode(',', $teacherroles);
-        foreach ($teacherroleids as $role) {
+        if (is_null($this->teacherroleids)) {
+            $this->teacherroleids = array_keys(get_archetype_roles('editingteacher') + get_archetype_roles('teacher'));
+        }
+
+        foreach ($this->teacherroleids as $role) {
             // We look for roles, not enrolments as a teacher assigned at category level is supposed to be a
             // course teacher.
             $teachers = get_role_users($role, $context, false, 'u.id', 'u.id');