Merge branch 'MDL-83654-500-5' of https://github.com/junpataleta/moodle into MOODLE_500_STABLE

This commit is contained in:
Mihail Geshoski
2025-06-05 11:00:24 +07:00
committed by Huong Nguyen
+22 -7
View File
@@ -43,23 +43,25 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
$choices = $this->format_choices($question);
$questiontextid = $qa->get_qt_field_name('qtext');
$result = '';
$result .= html_writer::tag('div', $question->format_questiontext($qa),
array('class' => 'qtext'));
array('class' => 'qtext', 'id' => $questiontextid));
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
$result .= html_writer::start_tag('table', array('class' => 'answer'));
$result .= html_writer::start_tag('tbody');
$result .= html_writer::start_tag('table', array('class' => 'answer', 'role' => 'presentation'));
$result .= html_writer::start_tag('tbody', ['role' => 'presentation']);
$parity = 0;
$i = 1;
foreach ($stemorder as $key => $stemid) {
$result .= html_writer::start_tag('tr', array('class' => 'r' . $parity));
$result .= html_writer::start_tag('tr', array('class' => 'r' . $parity, 'role' => 'presentation'));
$fieldname = 'sub' . $key;
$itemtextid = $qa->get_qt_field_name($fieldname . '_itemtext');
$result .= html_writer::tag('td', $this->format_stem_text($qa, $stemid),
array('class' => 'text'));
array('class' => 'text', 'id' => $itemtextid, 'role' => 'presentation'));
$classes = 'control';
$feedbackimage = '';
@@ -77,14 +79,27 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
$feedbackimage = $this->feedback_image($fraction);
}
// We only want to add the question text to the first answer field to
// avoid repetition of the question text for the subsequent answer fields.
if ($i == 1) {
$ariadescribedbyids = $questiontextid . ' ' . $itemtextid;
} else {
$ariadescribedbyids = $itemtextid;
}
$labeltext = $options->add_question_identifier_to_label(get_string('answer', 'qtype_match', $i));
$result .= html_writer::tag('td',
html_writer::label($labeltext,
'menu' . $qa->get_qt_field_name('sub' . $key), false,
array('class' => 'accesshide')) .
html_writer::select($choices, $qa->get_qt_field_name('sub' . $key), $selected,
['0' => 'choose'], ['disabled' => $options->readonly, 'class' => 'form-select d-inline-block ms-1']) .
' ' . $feedbackimage, array('class' => $classes));
['0' => 'choose'],
[
'disabled' => $options->readonly,
'class' => 'form-select d-inline-block ms-1',
'aria-describedby' => $ariadescribedbyids,
]) .
' ' . $feedbackimage, array('class' => $classes, 'role' => 'presentation'));
$result .= html_writer::end_tag('tr');
$parity = 1 - $parity;