original_string: public function display_publish_anonymous($choices, $displaylayout) {
          global $OUTPUT;
          $count = 0;
          $data = [];
          $numberofuser = 0;
          $percentageamount = 0;
          foreach ($choices->options as $optionid => $option) {
              if (!empty($option->user)) {
                  $numberofuser = count($option->user);
              }
              if($choices->numberofuser > 0) {
                  $percentageamount = ((float)$numberofuser / (float)$choices->numberofuser) * 100.0;
              }
              $data['labels'][$count] = $option->text;
              $data['series'][$count] = $numberofuser;
              $data['series_labels'][$count] = $numberofuser . ' (' . format_float($percentageamount, 1) . '%)';
              $count++;
              $numberofuser = 0;
          }
  
          $chart = new \core\chart_bar();
          if ($displaylayout == DISPLAY_HORIZONTAL_LAYOUT) {
              $chart->set_horizontal(true);
          }
          $series = new \core\chart_series(format_string(get_string("responses", "choice")), $data['series']);
          $series->set_labels($data['series_labels']);
          $chart->add_series($series);
          $chart->set_labels($data['labels']);
          $yaxis = $chart->get_yaxis(0, true);
          $yaxis->set_stepsize(max(1, round(max($data['series']) / 10)));
          return $OUTPUT->render($chart);
      }
code: public function display_publish_anonymous($choices, $displaylayout) {
          global $OUTPUT;
          $count = 0;
          $data = [];
          $numberofuser = 0;
          $percentageamount = 0;
          foreach ($choices->options as $optionid => $option) {
              if (!empty($option->user)) {
                  $numberofuser = count($option->user);
              }
              if($choices->numberofuser > 0) {
                  $percentageamount = ((float)$numberofuser / (float)$choices->numberofuser) * 100.0;
              }
              $data['labels'][$count] = $option->text;
              $data['series'][$count] = $numberofuser;
              $data['series_labels'][$count] = $numberofuser . ' (' . format_float($percentageamount, 1) . '%)';
              $count++;
              $numberofuser = 0;
          }
  
          $chart = new \core\chart_bar();
          if ($displaylayout == DISPLAY_HORIZONTAL_LAYOUT) {
              $chart->set_horizontal(true);
          }
          $series = new \core\chart_series(format_string(get_string("responses", "choice")), $data['series']);
          $series->set_labels($data['series_labels']);
          $chart->add_series($series);
          $chart->set_labels($data['labels']);
          $yaxis = $chart->get_yaxis(0, true);
          $yaxis->set_stepsize(max(1, round(max($data['series']) / 10)));
          return $OUTPUT->render($chart);
      }
code_tokens: public function display_publish_anonymous ( $ choices , $ displaylayout ) { global $ OUTPUT ; $ count = 0 ; $ data = [ ] ; $ numberofuser = 0 ; $ percentageamount = 0 ; foreach ( $ choices -> options as $ optionid => $ option ) { if ( ! empty ( $ option -> user ) ) { $ numberofuser = count ( $ option -> user ) ; } if ( $ choices -> numberofuser > 0 ) { $ percentageamount = ( ( float ) $ numberofuser / ( float ) $ choices -> numberofuser ) * 100.0 ; } $ data [ 'labels' ] [ $ count ] = $ option -> text ; $ data [ 'series' ] [ $ count ] = $ numberofuser ; $ data [ 'series_labels' ] [ $ count ] = $ numberofuser . ' (' . format_float ( $ percentageamount , 1 ) . '%)' ; $ count ++ ; $ numberofuser = 0 ; } $ chart = new \ core \ chart_bar ( ) ; if ( $ displaylayout == DISPLAY_HORIZONTAL_LAYOUT ) { $ chart -> set_horizontal ( true ) ; } $ series = new \ core \ chart_series ( format_string ( get_string ( "responses" , "choice" ) ) , $ data [ 'series' ] ) ; $ series -> set_labels ( $ data [ 'series_labels' ] ) ; $ chart -> add_series ( $ series ) ; $ chart -> set_labels ( $ data [ 'labels' ] ) ; $ yaxis = $ chart -> get_yaxis ( 0 , true ) ; $ yaxis -> set_stepsize ( max ( 1 , round ( max ( $ data [ 'series' ] ) / 10 ) ) ) ; return $ OUTPUT -> render ( $ chart ) ; }
docstring: Generate the choice result chart.
  
  Can be displayed either in the vertical or horizontal position.
  
  @param stdClass $choices Choices responses object.
  @param int $displaylayout The constants DISPLAY_HORIZONTAL_LAYOUT or DISPLAY_VERTICAL_LAYOUT.
  @return string the rendered chart.
docstring_tokens: Generate the choice result chart .