original_string: public function set_type_select($options) {
          if (!array_key_exists($this->value, $options)) {
              throw new \coding_exception('Options for select element must contain an option for the specified value');
          }
          if (count($options) < 2) {
              $this->editable = false;
          }
          $this->type = 'select';
  
          $pairedoptions = [];
          foreach ($options as $key => $value) {
              $pairedoptions[] = [
                  'key' => $key,
                  'value' => $value,
              ];
          }
          $this->options = json_encode($pairedoptions);
          if ($this->displayvalue === null) {
              $this->displayvalue = $options[$this->value];
          }
          return $this;
      }
code: public function set_type_select($options) {
          if (!array_key_exists($this->value, $options)) {
              throw new \coding_exception('Options for select element must contain an option for the specified value');
          }
          if (count($options) < 2) {
              $this->editable = false;
          }
          $this->type = 'select';
  
          $pairedoptions = [];
          foreach ($options as $key => $value) {
              $pairedoptions[] = [
                  'key' => $key,
                  'value' => $value,
              ];
          }
          $this->options = json_encode($pairedoptions);
          if ($this->displayvalue === null) {
              $this->displayvalue = $options[$this->value];
          }
          return $this;
      }
code_tokens: public function set_type_select ( $ options ) { if ( ! array_key_exists ( $ this -> value , $ options ) ) { throw new \ coding_exception ( 'Options for select element must contain an option for the specified value' ) ; } if ( count ( $ options ) < 2 ) { $ this -> editable = false ; } $ this -> type = 'select' ; $ pairedoptions = [ ] ; foreach ( $ options as $ key => $ value ) { $ pairedoptions [ ] = [ 'key' => $ key , 'value' => $ value , ] ; } $ this -> options = json_encode ( $ pairedoptions ) ; if ( $ this -> displayvalue === null ) { $ this -> displayvalue = $ options [ $ this -> value ] ; } return $ this ; }
docstring: Sets the element type to be a dropdown
  
  For select element specifying $displayvalue is optional, if null it will
  be assumed that $displayvalue = $options[$value].
  However displayvalue can still be specified if it needs icons and/or
  html links.
  
  If only one option specified, the element will not be editable.
  
  @param array $options associative array with dropdown options
  @return self
docstring_tokens: Sets the element type to be a dropdown