original_string: public static function get_user_competency($userid, $competencyid) {
          static::require_enabled();
          $existing = user_competency::get_multiple($userid, array($competencyid));
          $uc = array_pop($existing);
  
          if (!$uc) {
              $uc = user_competency::create_relation($userid, $competencyid);
              $uc->create();
          }
  
          if (!$uc->can_read()) {
              throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
                  'nopermissions', '');
          }
          return $uc;
      }
code: public static function get_user_competency($userid, $competencyid) {
          static::require_enabled();
          $existing = user_competency::get_multiple($userid, array($competencyid));
          $uc = array_pop($existing);
  
          if (!$uc) {
              $uc = user_competency::create_relation($userid, $competencyid);
              $uc->create();
          }
  
          if (!$uc->can_read()) {
              throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
                  'nopermissions', '');
          }
          return $uc;
      }
code_tokens: public static function get_user_competency ( $ userid , $ competencyid ) { static :: require_enabled ( ) ; $ existing = user_competency :: get_multiple ( $ userid , array ( $ competencyid ) ) ; $ uc = array_pop ( $ existing ) ; if ( ! $ uc ) { $ uc = user_competency :: create_relation ( $ userid , $ competencyid ) ; $ uc -> create ( ) ; } if ( ! $ uc -> can_read ( ) ) { throw new required_capability_exception ( $ uc -> get_context ( ) , 'moodle/competency:usercompetencyview' , 'nopermissions' , '' ) ; } return $ uc ; }
docstring: Get a user competency.
  
  @param int $userid The user ID.
  @param int $competencyid The competency ID.
  @return user_competency
docstring_tokens: Get a user competency .