original_string: public static function template_viewed($templateorid) {
          static::require_enabled();
          $template = $templateorid;
          if (!is_object($template)) {
              $template = new template($template);
          }
  
          // First we do a permissions check.
          if (!$template->can_read()) {
              throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
                  'nopermissions', '');
          }
  
          // Trigger a template viewed event.
          \core\event\competency_template_viewed::create_from_template($template)->trigger();
  
          return true;
      }
code: public static function template_viewed($templateorid) {
          static::require_enabled();
          $template = $templateorid;
          if (!is_object($template)) {
              $template = new template($template);
          }
  
          // First we do a permissions check.
          if (!$template->can_read()) {
              throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
                  'nopermissions', '');
          }
  
          // Trigger a template viewed event.
          \core\event\competency_template_viewed::create_from_template($template)->trigger();
  
          return true;
      }
code_tokens: public static function template_viewed ( $ templateorid ) { static :: require_enabled ( ) ; $ template = $ templateorid ; if ( ! is_object ( $ template ) ) { $ template = new template ( $ template ) ; } // First we do a permissions check. if ( ! $ template -> can_read ( ) ) { throw new required_capability_exception ( $ template -> get_context ( ) , 'moodle/competency:templateview' , 'nopermissions' , '' ) ; } // Trigger a template viewed event. \ core \ event \ competency_template_viewed :: create_from_template ( $ template ) -> trigger ( ) ; return true ; }
docstring: Template event viewed.
  
  Requires moodle/competency:templateview capability at the system context.
  
  @param mixed $templateorid The id or the template.
  @return boolean
docstring_tokens: Template event viewed .