original_string: public function output_html($data, $query='') {
          global $OUTPUT;
  
          $this->load_choices();
          $currentsetting = array();
          foreach ($data as $key) {
              if ($key != 'none' and array_key_exists($key, $this->choices)) {
                  $currentsetting[] = $key; // already selected first
              }
          }
  
          $context = (object) [
              'id' => $this->get_id(),
              'name' => $this->get_full_name(),
          ];
  
          $options = $this->choices;
          $selects = [];
          for ($i = 0; $i < count($this->choices) - 1; $i++) {
              if (!array_key_exists($i, $currentsetting)) {
                  $currentsetting[$i] = 'none';
              }
              $selects[] = [
                  'key' => $i,
                  'options' => array_map(function($option) use ($options, $currentsetting, $i) {
                      return [
                          'name' => $options[$option],
                          'value' => $option,
                          'selected' => $currentsetting[$i] == $option
                      ];
                  }, array_keys($options))
              ];
          }
          $context->selects = $selects;
  
          $element = $OUTPUT->render_from_template('core_admin/setting_courselist_frontpage', $context);
  
          return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', null, $query);
      }
code: public function output_html($data, $query='') {
          global $OUTPUT;
  
          $this->load_choices();
          $currentsetting = array();
          foreach ($data as $key) {
              if ($key != 'none' and array_key_exists($key, $this->choices)) {
                  $currentsetting[] = $key; // already selected first
              }
          }
  
          $context = (object) [
              'id' => $this->get_id(),
              'name' => $this->get_full_name(),
          ];
  
          $options = $this->choices;
          $selects = [];
          for ($i = 0; $i < count($this->choices) - 1; $i++) {
              if (!array_key_exists($i, $currentsetting)) {
                  $currentsetting[$i] = 'none';
              }
              $selects[] = [
                  'key' => $i,
                  'options' => array_map(function($option) use ($options, $currentsetting, $i) {
                      return [
                          'name' => $options[$option],
                          'value' => $option,
                          'selected' => $currentsetting[$i] == $option
                      ];
                  }, array_keys($options))
              ];
          }
          $context->selects = $selects;
  
          $element = $OUTPUT->render_from_template('core_admin/setting_courselist_frontpage', $context);
  
          return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', null, $query);
      }
code_tokens: public function output_html ( $ data , $ query = '' ) { global $ OUTPUT ; $ this -> load_choices ( ) ; $ currentsetting = array ( ) ; foreach ( $ data as $ key ) { if ( $ key != 'none' and array_key_exists ( $ key , $ this -> choices ) ) { $ currentsetting [ ] = $ key ; // already selected first } } $ context = ( object ) [ 'id' => $ this -> get_id ( ) , 'name' => $ this -> get_full_name ( ) , ] ; $ options = $ this -> choices ; $ selects = [ ] ; for ( $ i = 0 ; $ i < count ( $ this -> choices ) - 1 ; $ i ++ ) { if ( ! array_key_exists ( $ i , $ currentsetting ) ) { $ currentsetting [ $ i ] = 'none' ; } $ selects [ ] = [ 'key' => $ i , 'options' => array_map ( function ( $ option ) use ( $ options , $ currentsetting , $ i ) { return [ 'name' => $ options [ $ option ] , 'value' => $ option , 'selected' => $ currentsetting [ $ i ] == $ option ] ; } , array_keys ( $ options ) ) ] ; } $ context -> selects = $ selects ; $ element = $ OUTPUT -> render_from_template ( 'core_admin/setting_courselist_frontpage' , $ context ) ; return format_admin_setting ( $ this , $ this -> visiblename , $ element , $ this -> description , false , '' , null , $ query ) ; }
docstring: Return XHTML select field and wrapping div
  
  @todo Add vartype handling to make sure $data is an array
  @param array $data Array of elements to select by default
  @return string XHTML select field and wrapping div
docstring_tokens: Return XHTML select field and wrapping div