From bad9e0a1bc69ee3bfcd621b85d6138b01d39a7eb Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 17 Feb 2023 10:53:20 +0800 Subject: [PATCH] MDL-76849 qtype_gapselect: Include question number in answer fields --- question/type/gapselect/renderer.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/question/type/gapselect/renderer.php b/question/type/gapselect/renderer.php index e512550d349..4faea7767d5 100644 --- a/question/type/gapselect/renderer.php +++ b/question/type/gapselect/renderer.php @@ -44,10 +44,10 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_ $value = $qa->get_last_qt_var($question->field($place)); - $attributes = array( - 'id' => $this->box_id($qa, 'p' . $place), - 'class' => 'custom-select place' . $place, - ); + $attributes = [ + 'id' => $this->box_id($qa, 'p' . $place), + 'class' => 'custom-select place' . $place, + ]; $groupclass = 'group' . $group; if ($options->readonly) { @@ -55,7 +55,7 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_ } $orderedchoices = $question->get_ordered_choices($group); - $selectoptions = array(); + $selectoptions = []; foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) { $selectoptions[$orderedchoicevalue] = format_string($orderedchoice->text); } @@ -71,13 +71,12 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_ } } + $label = $options->add_question_identifier_to_label(get_string('blanknumber', 'qtype_gapselect', $place)); // Use non-breaking space instead of 'Choose...'. - $selecthtml = html_writer::label(get_string('blanknumber', 'qtype_gapselect', $place), - $attributes['id'], false, - array('class' => 'sr-only')); + $selecthtml = html_writer::label($label, $attributes['id'], false, ['class' => 'sr-only']); $selecthtml .= html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, ' ', $attributes) . ' ' . $feedbackimage; - return html_writer::tag('span', $selecthtml, array('class' => 'control '.$groupclass)); + return html_writer::tag('span', $selecthtml, ['class' => 'control '.$groupclass]); } } -- 2.11.4.GIT