public static function check_can_list_insights(\context $context, bool $return = false) {
        global $USER;

        if ($context->contextlevel === CONTEXT_USER && $context->instanceid == $USER->id) {
            $capability = 'moodle/analytics:listowninsights';
        } else {
            $capability = 'moodle/analytics:listinsights';
        }

        if ($return) {
            return has_capability($capability, $context);
        } else {
            require_capability($capability, $context);
        }
    }