original_string: public static function add_competency_to_template($templateid, $competencyid) {
          static::require_enabled();
          // First we do a permissions check.
          $template = new template($templateid);
          if (!$template->can_manage()) {
              throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
                  'nopermissions', '');
          }
  
          $record = new stdClass();
          $record->templateid = $templateid;
          $record->competencyid = $competencyid;
  
          $competency = new competency($competencyid);
  
          // Can not add a competency that belong to a hidden framework.
          if ($competency->get_framework()->get('visible') == false) {
              throw new coding_exception('A competency belonging to hidden framework can not be added');
          }
  
          $exists = template_competency::get_records(array('templateid' => $templateid, 'competencyid' => $competencyid));
          if (!$exists) {
              $templatecompetency = new template_competency(0, $record);
              $templatecompetency->create();
              return true;
          }
          return false;
      }
code: public static function add_competency_to_template($templateid, $competencyid) {
          static::require_enabled();
          // First we do a permissions check.
          $template = new template($templateid);
          if (!$template->can_manage()) {
              throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
                  'nopermissions', '');
          }
  
          $record = new stdClass();
          $record->templateid = $templateid;
          $record->competencyid = $competencyid;
  
          $competency = new competency($competencyid);
  
          // Can not add a competency that belong to a hidden framework.
          if ($competency->get_framework()->get('visible') == false) {
              throw new coding_exception('A competency belonging to hidden framework can not be added');
          }
  
          $exists = template_competency::get_records(array('templateid' => $templateid, 'competencyid' => $competencyid));
          if (!$exists) {
              $templatecompetency = new template_competency(0, $record);
              $templatecompetency->create();
              return true;
          }
          return false;
      }
code_tokens: public static function add_competency_to_template ( $ templateid , $ competencyid ) { static :: require_enabled ( ) ; // First we do a permissions check. $ template = new template ( $ templateid ) ; if ( ! $ template -> can_manage ( ) ) { throw new required_capability_exception ( $ template -> get_context ( ) , 'moodle/competency:templatemanage' , 'nopermissions' , '' ) ; } $ record = new stdClass ( ) ; $ record -> templateid = $ templateid ; $ record -> competencyid = $ competencyid ; $ competency = new competency ( $ competencyid ) ; // Can not add a competency that belong to a hidden framework. if ( $ competency -> get_framework ( ) -> get ( 'visible' ) == false ) { throw new coding_exception ( 'A competency belonging to hidden framework can not be added' ) ; } $ exists = template_competency :: get_records ( array ( 'templateid' => $ templateid , 'competencyid' => $ competencyid ) ) ; if ( ! $ exists ) { $ templatecompetency = new template_competency ( 0 , $ record ) ; $ templatecompetency -> create ( ) ; return true ; } return false ; }
docstring: Add a competency to this template.
  
  @param int $templateid The id of the template
  @param int $competencyid The id of the competency
  @return bool
docstring_tokens: Add a competency to this template .