From 91c7b05b057c97140e44748156dd7aee2edd72f6 Mon Sep 17 00:00:00 2001 From: Laurent David Date: Tue, 25 Oct 2022 10:11:00 +0200 Subject: [PATCH] MDL-76071 mod_choice: fix choice display on graphs * The setting "Display mode" modifies the choices alignment of radio choice button from horizontally to vertically. It should also display the list of choices in the graph in the same directions. --- mod/choice/renderer.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mod/choice/renderer.php b/mod/choice/renderer.php index 4f954bb0f20..725a1b7bce2 100644 --- a/mod/choice/renderer.php +++ b/mod/choice/renderer.php @@ -22,9 +22,6 @@ * @copyright 2010 Rossiani Wijaya * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ -define ('DISPLAY_HORIZONTAL_LAYOUT', 0); -define ('DISPLAY_VERTICAL_LAYOUT', 1); - class mod_choice_renderer extends plugin_renderer_base { /** @@ -375,7 +372,7 @@ class mod_choice_renderer extends plugin_renderer_base { * 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. + * @param int $displaylayout The constants CHOICE_DISPLAY_HORIZONTAL or CHOICE_DISPLAY_VERTICAL. * @return string the rendered chart. */ public function display_publish_anonymous($choices, $displaylayout) { @@ -398,8 +395,8 @@ class mod_choice_renderer extends plugin_renderer_base { } $chart = new \core\chart_bar(); - if ($displaylayout == DISPLAY_HORIZONTAL_LAYOUT) { - $chart->set_horizontal(true); + if ($displaylayout == CHOICE_DISPLAY_VERTICAL) { + $chart->set_horizontal(true); // Horizontal bars when choices are vertical. } $series = new \core\chart_series(format_string(get_string("responses", "choice")), $data['series']); $series->set_labels($data['series_labels']);