original_string: protected function validate_scaleid($value) {
          global $DB;
  
          // Always validate that the scale exists.
          if (!$DB->record_exists_select('scale', 'id = :id', array('id' => $value))) {
              return new lang_string('invalidscaleid', 'error');
          }
  
          // During update.
          if ($this->get('id')) {
  
              // Validate that we can only change the scale when it is not used yet.
              if ($this->beforeupdate->get('scaleid') != $value) {
                  if ($this->beforeupdate->has_user_competencies()) {
                      return new lang_string('errorscalealreadyused', 'core_competency');
                  }
              }
  
          }
  
          return true;
      }
code: protected function validate_scaleid($value) {
          global $DB;
  
          // Always validate that the scale exists.
          if (!$DB->record_exists_select('scale', 'id = :id', array('id' => $value))) {
              return new lang_string('invalidscaleid', 'error');
          }
  
          // During update.
          if ($this->get('id')) {
  
              // Validate that we can only change the scale when it is not used yet.
              if ($this->beforeupdate->get('scaleid') != $value) {
                  if ($this->beforeupdate->has_user_competencies()) {
                      return new lang_string('errorscalealreadyused', 'core_competency');
                  }
              }
  
          }
  
          return true;
      }
code_tokens: protected function validate_scaleid ( $ value ) { global $ DB ; // Always validate that the scale exists. if ( ! $ DB -> record_exists_select ( 'scale' , 'id = :id' , array ( 'id' => $ value ) ) ) { return new lang_string ( 'invalidscaleid' , 'error' ) ; } // During update. if ( $ this -> get ( 'id' ) ) { // Validate that we can only change the scale when it is not used yet. if ( $ this -> beforeupdate -> get ( 'scaleid' ) != $ value ) { if ( $ this -> beforeupdate -> has_user_competencies ( ) ) { return new lang_string ( 'errorscalealreadyused' , 'core_competency' ) ; } } } return true ; }
docstring: Validate the scale ID.
  
  @param  string $value The scale ID.
  @return bool|lang_string
docstring_tokens: Validate the scale ID .