original_string: public static function user_competency_cancel_review_request($userid, $competencyid) {
          static::require_enabled();
          $context = context_user::instance($userid);
          $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          if (!$uc || !$uc->can_read()) {
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', '');
          } else if ($uc->get('status') != user_competency::STATUS_WAITING_FOR_REVIEW) {
              throw new coding_exception('The competency can not be cancel review request at this stage.');
          } else if (!$uc->can_request_review()) {
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyrequestreview', 'nopermissions', '');
          }
  
          $uc->set('status', user_competency::STATUS_IDLE);
          $result = $uc->update();
          if ($result) {
              \core\event\competency_user_competency_review_request_cancelled::create_from_user_competency($uc)->trigger();
          }
          return $result;
      }
code: public static function user_competency_cancel_review_request($userid, $competencyid) {
          static::require_enabled();
          $context = context_user::instance($userid);
          $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
          if (!$uc || !$uc->can_read()) {
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', '');
          } else if ($uc->get('status') != user_competency::STATUS_WAITING_FOR_REVIEW) {
              throw new coding_exception('The competency can not be cancel review request at this stage.');
          } else if (!$uc->can_request_review()) {
              throw new required_capability_exception($context, 'moodle/competency:usercompetencyrequestreview', 'nopermissions', '');
          }
  
          $uc->set('status', user_competency::STATUS_IDLE);
          $result = $uc->update();
          if ($result) {
              \core\event\competency_user_competency_review_request_cancelled::create_from_user_competency($uc)->trigger();
          }
          return $result;
      }
code_tokens: public static function user_competency_cancel_review_request ( $ userid , $ competencyid ) { static :: require_enabled ( ) ; $ context = context_user :: instance ( $ userid ) ; $ uc = user_competency :: get_record ( array ( 'userid' => $ userid , 'competencyid' => $ competencyid ) ) ; if ( ! $ uc || ! $ uc -> can_read ( ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:usercompetencyview' , 'nopermissions' , '' ) ; } else if ( $ uc -> get ( 'status' ) != user_competency :: STATUS_WAITING_FOR_REVIEW ) { throw new coding_exception ( 'The competency can not be cancel review request at this stage.' ) ; } else if ( ! $ uc -> can_request_review ( ) ) { throw new required_capability_exception ( $ context , 'moodle/competency:usercompetencyrequestreview' , 'nopermissions' , '' ) ; } $ uc -> set ( 'status' , user_competency :: STATUS_IDLE ) ; $ result = $ uc -> update ( ) ; if ( $ result ) { \ core \ event \ competency_user_competency_review_request_cancelled :: create_from_user_competency ( $ uc ) -> trigger ( ) ; } return $ result ; }
docstring: Cancel a user competency review request.
  
  @param  int $userid       The user ID.
  @param  int $competencyid The competency ID.
  @return bool
docstring_tokens: Cancel a user competency review request .