original_string: 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);
          }
      }
code: 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);
          }
      }
code_tokens: 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 ) ; } }
docstring: 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
docstring_tokens: Checks that the user can list that context insights