Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 108... Línea 108...
108
            if ($question->answernumbering !== 'none') {
108
            if ($question->answernumbering !== 'none') {
109
                $choicenumber = html_writer::span(
109
                $choicenumber = html_writer::span(
110
                        $this->number_in_style($value, $question->answernumbering), 'answernumber');
110
                        $this->number_in_style($value, $question->answernumbering), 'answernumber');
111
            }
111
            }
112
            $choicetext = $question->format_text($ans->answer, $ans->answerformat, $qa, 'question', 'answer', $ansid);
112
            $choicetext = $question->format_text($ans->answer, $ans->answerformat, $qa, 'question', 'answer', $ansid);
113
            $choice = html_writer::div($choicetext, 'flex-fill ml-1');
113
            $choice = html_writer::div($choicetext, 'flex-fill ms-1');
Línea 114... Línea 114...
114
 
114
 
115
            $radiobuttons[] = $hidden . html_writer::empty_tag('input', $inputattributes) .
115
            $radiobuttons[] = $hidden . html_writer::empty_tag('input', $inputattributes) .
116
                    html_writer::div($choicenumber . $choice, 'd-flex w-auto', [
116
                    html_writer::div($choicenumber . $choice, 'd-flex w-auto', [
117
                        'id' => $inputattributes['id'] . '_label',
117
                        'id' => $inputattributes['id'] . '_label',
Línea 133... Línea 133...
133
            if ($options->correctness && $isselected) {
133
            if ($options->correctness && $isselected) {
134
                // Feedback images will be rendered using Font awesome.
134
                // Feedback images will be rendered using Font awesome.
135
                // Font awesome icons are actually characters(text) with special glyphs,
135
                // Font awesome icons are actually characters(text) with special glyphs,
136
                // so the icons cannot be aligned correctly even if the parent div wrapper is using align-items: flex-start.
136
                // so the icons cannot be aligned correctly even if the parent div wrapper is using align-items: flex-start.
137
                // To make the Font awesome icons follow align-items: flex-start, we need to wrap them inside a span tag.
137
                // To make the Font awesome icons follow align-items: flex-start, we need to wrap them inside a span tag.
138
                $feedbackimg[] = html_writer::span($this->feedback_image($this->is_right($ans)), 'ml-1');
138
                $feedbackimg[] = html_writer::span($this->feedback_image($this->is_right($ans)), 'ms-1');
139
                $class .= ' ' . $this->feedback_class($this->is_right($ans));
139
                $class .= ' ' . $this->feedback_class($this->is_right($ans));
140
            } else {
140
            } else {
141
                $feedbackimg[] = '';
141
                $feedbackimg[] = '';
142
            }
142
            }
143
            $classes[] = $class;
143
            $classes[] = $class;
Línea 151... Línea 151...
151
        if ($question->showstandardinstruction == 1) {
151
        if ($question->showstandardinstruction == 1) {
152
            $legendclass = '';
152
            $legendclass = '';
153
            $questionnumber = $options->add_question_identifier_to_label($this->prompt(), true, true);
153
            $questionnumber = $options->add_question_identifier_to_label($this->prompt(), true, true);
154
        } else {
154
        } else {
155
            $questionnumber = $options->add_question_identifier_to_label(get_string('answer'), true, true);
155
            $questionnumber = $options->add_question_identifier_to_label(get_string('answer'), true, true);
156
            $legendclass = 'sr-only';
156
            $legendclass = 'visually-hidden';
157
        }
157
        }
158
        $legendattrs = [
158
        $legendattrs = [
159
            'class' => 'prompt h6 font-weight-normal ' . $legendclass,
159
            'class' => 'prompt h6 fw-normal ' . $legendclass,
160
        ];
160
        ];
161
        $result .= html_writer::tag('legend', $questionnumber, $legendattrs);
161
        $result .= html_writer::tag('legend', $questionnumber, $legendattrs);
Línea 162... Línea 162...
162
 
162
 
163
        $result .= html_writer::start_tag('div', array('class' => 'answer'));
163
        $result .= html_writer::start_tag('div', array('class' => 'answer'));
Línea 310... Línea 310...
310
        $clearchoiceradioattrs = [
310
        $clearchoiceradioattrs = [
311
            'type' => $this->get_input_type(),
311
            'type' => $this->get_input_type(),
312
            'name' => $qa->get_qt_field_name('answer'),
312
            'name' => $qa->get_qt_field_name('answer'),
313
            'id' => $clearchoiceid,
313
            'id' => $clearchoiceid,
314
            'value' => -1,
314
            'value' => -1,
315
            'class' => 'sr-only',
315
            'class' => 'visually-hidden',
316
            'aria-hidden' => 'true'
316
            'aria-hidden' => 'true'
317
        ];
317
        ];
318
        $clearchoicewrapperattrs = [
318
        $clearchoicewrapperattrs = [
319
            'id' => $clearchoicefieldname,
319
            'id' => $clearchoicefieldname,
320
            'class' => 'qtype_multichoice_clearchoice',
320
            'class' => 'qtype_multichoice_clearchoice',
321
        ];
321
        ];
Línea 322... Línea 322...
322
 
322
 
323
        // When no choice selected during rendering, then hide the clear choice option.
323
        // When no choice selected during rendering, then hide the clear choice option.
324
        // We are using .sr-only and aria-hidden together so while the element is hidden
324
        // We are using .visually-hidden and aria-hidden together so while the element is hidden
325
        // from both the monitor and the screen-reader, it is still tabbable.
325
        // from both the monitor and the screen-reader, it is still tabbable.
326
        $linktabindex = 0;
326
        $linktabindex = 0;
327
        if (!$hascheckedchoice && $response == -1) {
327
        if (!$hascheckedchoice && $response == -1) {
328
            $clearchoicewrapperattrs['class'] .= ' sr-only';
328
            $clearchoicewrapperattrs['class'] .= ' visually-hidden';
329
            $clearchoicewrapperattrs['aria-hidden'] = 'true';
329
            $clearchoicewrapperattrs['aria-hidden'] = 'true';
330
            $clearchoiceradioattrs['checked'] = 'checked';
330
            $clearchoiceradioattrs['checked'] = 'checked';
331
            $linktabindex = -1;
331
            $linktabindex = -1;
332
        }
332
        }
333
        // Adds an hidden radio that will be checked to give the impression the choice has been cleared.
333
        // Adds an hidden radio that will be checked to give the impression the choice has been cleared.
334
        $clearchoiceradio = html_writer::empty_tag('input', $clearchoiceradioattrs);
334
        $clearchoiceradio = html_writer::empty_tag('input', $clearchoiceradioattrs);
335
        $clearchoice = html_writer::link('#', get_string('clearchoice', 'qtype_multichoice'),
335
        $clearchoice = html_writer::link('#', get_string('clearchoice', 'qtype_multichoice'),
336
            ['tabindex' => $linktabindex, 'role' => 'button', 'class' => 'btn btn-link ml-3 mt-n1']);
336
            ['tabindex' => $linktabindex, 'role' => 'button', 'class' => 'btn btn-link ms-3 mt-n1']);
Línea 337... Línea 337...
337
        $clearchoiceradio .= html_writer::label($clearchoice, $clearchoiceid);
337
        $clearchoiceradio .= html_writer::label($clearchoice, $clearchoiceid);
338
 
338