original_string: public static function user_competency_request_review($userid, $competencyid) {
          static::require_enabled();
          $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          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', '');
          } else if ($uc->get('status') != user_competency::STATUS_IDLE) {
              throw new coding_exception('The competency can not be sent for review at this stage.');
          } else if (!$uc->can_request_review()) {
              throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyrequestreview',
                  'nopermissions', '');
          }
  
          $uc->set('status', user_competency::STATUS_WAITING_FOR_REVIEW);
          $result = $uc->update();
          if ($result) {
              \core\event\competency_user_competency_review_requested::create_from_user_competency($uc)->trigger();
          }
          return $result;
      }
code: public static function user_competency_request_review($userid, $competencyid) {
          static::require_enabled();
          $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          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', '');
          } else if ($uc->get('status') != user_competency::STATUS_IDLE) {
              throw new coding_exception('The competency can not be sent for review at this stage.');
          } else if (!$uc->can_request_review()) {
              throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyrequestreview',
                  'nopermissions', '');
          }
  
          $uc->set('status', user_competency::STATUS_WAITING_FOR_REVIEW);
          $result = $uc->update();
          if ($result) {
              \core\event\competency_user_competency_review_requested::create_from_user_competency($uc)->trigger();
          }
          return $result;
      }
code_tokens: public static function user_competency_request_review ( $ userid , $ competencyid ) { static :: require_enabled ( ) ; $ uc = user_competency :: get_record ( array ( 'userid' => $ userid , 'competencyid' => $ competencyid ) ) ; 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' , '' ) ; } else if ( $ uc -> get ( 'status' ) != user_competency :: STATUS_IDLE ) { throw new coding_exception ( 'The competency can not be sent for review at this stage.' ) ; } else if ( ! $ uc -> can_request_review ( ) ) { throw new required_capability_exception ( $ uc -> get_context ( ) , 'moodle/competency:usercompetencyrequestreview' , 'nopermissions' , '' ) ; } $ uc -> set ( 'status' , user_competency :: STATUS_WAITING_FOR_REVIEW ) ; $ result = $ uc -> update ( ) ; if ( $ result ) { \ core \ event \ competency_user_competency_review_requested :: create_from_user_competency ( $ uc ) -> trigger ( ) ; } return $ result ; }
docstring: Request a user competency review.
  
  @param  int $userid       The user ID.
  @param  int $competencyid The competency ID.
  @return bool
docstring_tokens: Request a user competency review .