From 787278601c134c3ab030c74b51421dfbc92b2df2 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 17 Feb 2023 15:32:21 +0800 Subject: [PATCH] MDL-76849 qtype_shortanswer: Include question number in answer fields --- question/type/shortanswer/renderer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/question/type/shortanswer/renderer.php b/question/type/shortanswer/renderer.php index 5ab0b76fa9a..8ca321e898a 100644 --- a/question/type/shortanswer/renderer.php +++ b/question/type/shortanswer/renderer.php @@ -75,8 +75,8 @@ class qtype_shortanswer_renderer extends qtype_renderer { $input = html_writer::empty_tag('input', $inputattributes) . $feedbackimg; if ($placeholder) { - $inputinplace = html_writer::tag('label', get_string('answer'), - array('for' => $inputattributes['id'], 'class' => 'accesshide')); + $inputinplace = html_writer::tag('label', $options->add_question_identifier_to_label(get_string('answer')), + array('for' => $inputattributes['id'], 'class' => 'sr-only')); $inputinplace .= $input; $questiontext = substr_replace($questiontext, $inputinplace, strpos($questiontext, $placeholder), strlen($placeholder)); @@ -86,8 +86,9 @@ class qtype_shortanswer_renderer extends qtype_renderer { if (!$placeholder) { $result .= html_writer::start_tag('div', array('class' => 'ablock form-inline')); - $result .= html_writer::tag('label', get_string('answer', 'qtype_shortanswer', - html_writer::tag('span', $input, array('class' => 'answer'))), + $answerspan = html_writer::tag('span', $input, array('class' => 'answer')); + $label = $options->add_question_identifier_to_label(get_string('answercolon', 'qtype_numerical'), true); + $result .= html_writer::tag('label', $label . $answerspan, array('for' => $inputattributes['id'])); $result .= html_writer::end_tag('div'); }