original_string: public static function count_templates_using_competency($competencyid) {
          static::require_enabled();
          // First we do a permissions check.
          $context = context_system::instance();
          $onlyvisible = 1;
  
          $capabilities = array('moodle/competency:templateview', 'moodle/competency:templatemanage');
          if (!has_any_capability($capabilities, $context)) {
               throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
          }
  
          if (has_capability('moodle/competency:templatemanage', $context)) {
              $onlyvisible = 0;
          }
  
          // OK - all set.
          return template_competency::count_templates($competencyid, $onlyvisible);
      }
code: public static function count_templates_using_competency($competencyid) {
          static::require_enabled();
          // First we do a permissions check.
          $context = context_system::instance();
          $onlyvisible = 1;
  
          $capabilities = array('moodle/competency:templateview', 'moodle/competency:templatemanage');
          if (!has_any_capability($capabilities, $context)) {
               throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
          }
  
          if (has_capability('moodle/competency:templatemanage', $context)) {
              $onlyvisible = 0;
          }
  
          // OK - all set.
          return template_competency::count_templates($competencyid, $onlyvisible);
      }
code_tokens: public static function count_templates_using_competency ( $ competencyid ) { static :: require_enabled ( ) ; // First we do a permissions check. $ context = context_system :: instance ( ) ; $ onlyvisible = 1 ; $ capabilities = array ( 'moodle/competency:templateview' , 'moodle/competency:templatemanage' ) ; if ( ! has_any_capability ( $ capabilities , $ context ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:templateview' , 'nopermissions' , '' ) ; } if ( has_capability ( 'moodle/competency:templatemanage' , $ context ) ) { $ onlyvisible = 0 ; } // OK - all set. return template_competency :: count_templates ( $ competencyid , $ onlyvisible ) ; }
docstring: Count all the templates using a competency.
  
  @param int $competencyid The id of the competency to check.
  @return int
docstring_tokens: Count all the templates using a competency .