Skip to content

Commit

Permalink
MDL-76849 qtype_gapselect: Include question number in answer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Mar 9, 2023
1 parent fb65143 commit fdc24f0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions question/type/gapselect/renderer.php
Expand Up @@ -44,18 +44,18 @@ protected function embedded_element(question_attempt $qa, $place,

$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) {
$attributes['disabled'] = 'disabled';
}

$orderedchoices = $question->get_ordered_choices($group);
$selectoptions = array();
$selectoptions = [];
foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) {
$selectoptions[$orderedchoicevalue] = format_string($orderedchoice->text);
}
Expand All @@ -71,13 +71,12 @@ protected function embedded_element(question_attempt $qa, $place,
}
}

$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]);
}

}

0 comments on commit fdc24f0

Please sign in to comment.