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);
        }
    }
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);
        }
    }
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 ) ; } }
Checks that the user can list that context insights

@throws \required_capability_exception
@param \context $context
@param  bool $return The method returns a bool if true.
@return void
Checks that the user can list that context insights