public function get_insights_users(\context $context) {
        if ($context->contextlevel === CONTEXT_USER) {
            $users = [$context->instanceid => \core_user::get_user($context->instanceid)];
        } else if ($context->contextlevel >= CONTEXT_COURSE) {
            // At course level or below only enrolled users although this is not ideal for
            // teachers assigned at category level.
            $users = get_enrolled_users($context, 'moodle/analytics:listinsights');
        } else {
            $users = get_users_by_capability($context, 'moodle/analytics:listinsights');
        }
        return $users;
    }