original_string: public function create_competency($record, $parent, $framework) {
          $competency = new stdClass();
          $competency->competencyframeworkid = $framework->get('id');
          $competency->shortname = $record->shortname;
          if (!empty($record->description)) {
              $competency->description = $record->description;
              $competency->descriptionformat = $record->descriptionformat;
          }
          if ($record->scalevalues) {
              $competency->scaleid = $this->get_scale_id($record->scalevalues, $competency->shortname);
              $competency->scaleconfiguration = $this->get_scale_configuration($competency->scaleid, $record->scaleconfiguration);
          }
          if ($parent) {
              $competency->parentid = $parent->get('id');
          } else {
              $competency->parentid = 0;
          }
          $competency->idnumber = $record->idnumber;
  
          if (!empty($competency->idnumber) && !empty($competency->shortname)) {
              $comp = api::create_competency($competency);
              if ($record->exportid) {
                  $this->mappings[$record->exportid] = $comp;
              }
              $record->createdcomp = $comp;
              foreach ($record->children as $child) {
                  $this->create_competency($child, $comp, $framework);
              }
  
              return $comp;
          }
          return false;
      }
code: public function create_competency($record, $parent, $framework) {
          $competency = new stdClass();
          $competency->competencyframeworkid = $framework->get('id');
          $competency->shortname = $record->shortname;
          if (!empty($record->description)) {
              $competency->description = $record->description;
              $competency->descriptionformat = $record->descriptionformat;
          }
          if ($record->scalevalues) {
              $competency->scaleid = $this->get_scale_id($record->scalevalues, $competency->shortname);
              $competency->scaleconfiguration = $this->get_scale_configuration($competency->scaleid, $record->scaleconfiguration);
          }
          if ($parent) {
              $competency->parentid = $parent->get('id');
          } else {
              $competency->parentid = 0;
          }
          $competency->idnumber = $record->idnumber;
  
          if (!empty($competency->idnumber) && !empty($competency->shortname)) {
              $comp = api::create_competency($competency);
              if ($record->exportid) {
                  $this->mappings[$record->exportid] = $comp;
              }
              $record->createdcomp = $comp;
              foreach ($record->children as $child) {
                  $this->create_competency($child, $comp, $framework);
              }
  
              return $comp;
          }
          return false;
      }
code_tokens: public function create_competency ( $ record , $ parent , $ framework ) { $ competency = new stdClass ( ) ; $ competency -> competencyframeworkid = $ framework -> get ( 'id' ) ; $ competency -> shortname = $ record -> shortname ; if ( ! empty ( $ record -> description ) ) { $ competency -> description = $ record -> description ; $ competency -> descriptionformat = $ record -> descriptionformat ; } if ( $ record -> scalevalues ) { $ competency -> scaleid = $ this -> get_scale_id ( $ record -> scalevalues , $ competency -> shortname ) ; $ competency -> scaleconfiguration = $ this -> get_scale_configuration ( $ competency -> scaleid , $ record -> scaleconfiguration ) ; } if ( $ parent ) { $ competency -> parentid = $ parent -> get ( 'id' ) ; } else { $ competency -> parentid = 0 ; } $ competency -> idnumber = $ record -> idnumber ; if ( ! empty ( $ competency -> idnumber ) && ! empty ( $ competency -> shortname ) ) { $ comp = api :: create_competency ( $ competency ) ; if ( $ record -> exportid ) { $ this -> mappings [ $ record -> exportid ] = $ comp ; } $ record -> createdcomp = $ comp ; foreach ( $ record -> children as $ child ) { $ this -> create_competency ( $ child , $ comp , $ framework ) ; } return $ comp ; } return false ; }
docstring: Recursive function to add a competency with all it's children.
  
  @param stdClass $record Raw data for the new competency
  @param competency $parent
  @param competency_framework $framework
docstring_tokens: Recursive function to add a competency with all it s children .