Permalink
Browse files

MDL-34570 accessibility compliance for question: edit string label

  • Loading branch information...
1 parent 9273bd1 commit daa3c5ff1b8dfafb494d41c7b8357a5aeea1a650 @rwijaya rwijaya committed with FMCorz Jul 31, 2012
View
3 question/behaviour/rendererbase.php
@@ -88,12 +88,13 @@ public function manual_comment_fields(question_attempt $qa, question_display_opt
array('id' => $id, 'name' => $inputname, 'rows' => 10, 'cols' => 60)));
$commenteditor .= html_writer::start_tag('div');
- if (count($formats == 1)) {
+ if (count($formats) == 1) {
reset($formats);
$commenteditor .= html_writer::empty_tag('input', array('type' => 'hidden',
'name' => $inputname . 'format', 'value' => key($formats)));
} else {
+ $commenteditor .= html_writer::label(get_string('formattexttype'), 'menu' . $inputname . 'format', false, array('class' => 'accesshide'));
$commenteditor .= html_writer::select(
$formats, $inputname . 'format', $commentformat, '');
}
View
9 question/format/xhtml/format.php
@@ -95,12 +95,14 @@ protected function writequestion($question) {
break;
case SHORTANSWER:
$expout .= "<ul class=\"shortanswer\">\n";
- $expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
+ $expout .= " <li>" . html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
+ $expout .= " <input id=\"quest_$id\" name=\"quest_$id\" type=\"text\" /></li>\n";
$expout .= "</ul>\n";
break;
case NUMERICAL:
$expout .= "<ul class=\"numerical\">\n";
- $expout .= " <li><input name=\"quest_$id\" type=\"text\" /></li>\n";
+ $expout .= " <li>" . html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
+ $expout .= " <input id=\"quest_$id\" name=\"quest_$id\" type=\"text\" /></li>\n";
$expout .= "</ul>\n";
break;
case MATCH:
@@ -114,7 +116,8 @@ protected function writequestion($question) {
shuffle( $ans_list ); // random display order
// build drop down for answers
- $dropdown = "<select name=\"quest_$id\">\n";
+ $dropdown = html_writer::label(get_string('selectansweroption'), 'quest_'.$id, false, array('class' => 'accesshide'));
+ $dropdown .= "<select id=\"quest_$id\" name=\"quest_$id\">\n";
foreach($ans_list as $ans) {
$dropdown .= "<option value=\"" . s($ans) . "\">" . s($ans) . "</option>\n";
}
View
1 question/format/xhtml/lang/en/qformat_xhtml.php
@@ -26,3 +26,4 @@
$string['pluginname'] = 'XHTML format';
$string['pluginname_help'] = 'XHTML format enables all questions in the category to be exported to a single page of strict XHTML for possible use in another application.';
$string['pluginname_link'] = 'qformat/xhtml';
+$string['selectansweroption'] = 'Select answer option';
View
2 question/type/calculated/lang/en/qtype_calculated.php
@@ -49,6 +49,7 @@
$string['decimals'] = 'with {$a}';
$string['deleteitem'] = 'Delete item';
$string['deletelastitem'] = 'Delete last item';
+$string['distributionoption'] = 'Select distribution option';
$string['editdatasets'] = 'Edit the wildcards datasets';
$string['editdatasets_help'] = 'Wildcard values may be created by entering a number in each wild card field then clicking the add button. To automatically generate 10 or more values, select the number of values required before clicking the add button. A uniform distribution means any value between the limits is equally likely to be generated; a loguniform distribution means that values towards the lower limit are more likely.';
$string['editdatasets_link'] = 'question/type/calculated';
@@ -79,6 +80,7 @@
$string['keptlocal2'] = 'a file from the same question private set of files as before';
$string['keptlocal3'] = 'a link from the same question private set of links as before';
$string['lastitem(s)'] = 'last items(s)';
+$string['lengthoption'] = 'Select length option';
$string['loguniform'] = 'Loguniform';
$string['loguniformbit'] = 'digits, from a loguniform distribution';
$string['makecopynextpage'] = 'Next page (new question)';
View
6 question/type/calculated/questiontype.php
@@ -751,11 +751,13 @@ public function custom_generator_tools($datasetdef) {
? 'decimals'
: 'significantfigures'), 'qtype_calculated', $i);
}
- $menu1 = html_writer::select($lengthoptions, 'calclength[]', $regs[4], null);
+ $menu1 = html_writer::label(get_string('lengthoption', 'qtype_calculated'), 'menucalclength', false, array('class' => 'accesshide'));
+ $menu1 .= html_writer::select($lengthoptions, 'calclength[]', $regs[4], null);
$options = array('uniform' => get_string('uniformbit', 'qtype_calculated'),
'loguniform' => get_string('loguniformbit', 'qtype_calculated'));
- $menu2 = html_writer::select($options, 'calcdistribution[]', $regs[1], null);
+ $menu2 = html_writer::label(get_string('distributionoption', 'qtype_calculated'), 'menucalcdistribution', false, array('class' => 'accesshide'));
+ $menu2 .= html_writer::select($options, 'calcdistribution[]', $regs[1], null);
return '<input type="submit" onclick="'
. "getElementById('addform').regenerateddefid.value='$defid'; return true;"
.'" value="'. get_string('generatevalue', 'qtype_calculated') . '"/><br/>'
View
1 question/type/essay/lang/en/qtype_essay.php
@@ -38,3 +38,4 @@
$string['pluginnamesummary'] = 'Allows a response of a few sentences or paragraphs. This must then be graded manually.';
$string['responsefieldlines'] = 'Input box size';
$string['responseformat'] = 'Response format';
+$string['selectanswerformat'] = 'Select answer format';
View
3 question/type/essay/renderer.php
@@ -219,12 +219,13 @@ public function response_area_input($name, $qa, $step, $lines, $context) {
array('id' => $id, 'name' => $inputname, 'rows' => $lines, 'cols' => 60)));
$output .= html_writer::start_tag('div');
- if (count($formats == 1)) {
+ if (count($formats) == 1) {
reset($formats);
$output .= html_writer::empty_tag('input', array('type' => 'hidden',
'name' => $inputname . 'format', 'value' => key($formats)));
} else {
+ $output .= html_writer::label(get_string('selectanswerformat'), 'menu' . $inputname . 'format', false, array("class" => 'accesshide'));
$output .= html_writer::select($formats, $inputname . 'format', $responseformat, '');
}
$output .= html_writer::end_tag('div');
View
1 question/type/match/lang/en/qtype_match.php
@@ -40,3 +40,4 @@
$string['pluginnameadding'] = 'Adding a Matching question';
$string['pluginnameediting'] = 'Editing a Matching question';
$string['pluginnamesummary'] = 'The answer to each of a number of sub-question must be selected from a list of possibilities.';
+$string['selectananswer'] = 'Select an answer';
View
1 question/type/match/renderer.php
@@ -80,6 +80,7 @@ public function formulation_and_controls(question_attempt $qa,
}
$result .= html_writer::tag('td',
+ html_writer::label(get_string('selectananswer', 'qtype_match'), 'menu' . $qa->get_qt_field_name('sub' . $key), false, array('class' => 'accesshide')) .
html_writer::select($choices, $qa->get_qt_field_name('sub' . $key), $selected,
array('0' => 'choose'), array('disabled' => $options->readonly)) .
' ' . $feedbackimage, array('class' => $classes));
View
6 question/type/multianswer/renderer.php
@@ -223,7 +223,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti
s($correctanswer->answer), $options);
$output = '';
- $output .= html_writer::start_tag('label', array('class' => 'subq'));
+ $output .= html_writer::start_tag('label', array('class' => 'subq', 'for' => $inputattributes['id']));
$output .= html_writer::empty_tag('input', $inputattributes);
$output .= $feedbackimg;
$output .= $feedbackpopup;
@@ -274,8 +274,8 @@ public function subquestion(question_attempt $qa, question_display_options $opti
$inputattributes['class'] = $this->feedback_class($matchinganswer->fraction);
$feedbackimg = $this->feedback_image($matchinganswer->fraction);
}
-
- $select = html_writer::select($choices, $qa->get_qt_field_name($fieldname),
+ $select = html_writer::label($response, $inputattributes['id'], false, array('class' => 'accesshide'));
+ $select .= html_writer::select($choices, $qa->get_qt_field_name($fieldname),
$response, array('' => ''), $inputattributes);
$order = $subq->get_order($qa);
View
7 question/type/numerical/renderer.php
@@ -76,7 +76,8 @@ public function formulation_and_controls(question_attempt $qa,
$inputattributes['size'] = round(strlen($placeholder) * 1.1);
}
- $input = html_writer::empty_tag('input', $inputattributes) . $feedbackimg;
+ $input = html_writer::label($inputattributes['name'], $inputattributes['id'], false, array('class' => 'accesshide'));
+ $input .= html_writer::empty_tag('input', $inputattributes) . $feedbackimg;
if ($question->has_separate_unit_field()) {
if ($question->unitdisplay == qtype_numerical::UNITRADIO) {
@@ -98,7 +99,9 @@ public function formulation_and_controls(question_attempt $qa,
array('class' => 'unitchoices'));
} else if ($question->unitdisplay == qtype_numerical::UNITSELECT) {
- $unitchoice = html_writer::select($question->ap->get_unit_options(),
+ $unitchoice = html_writer::label(get_string('selectunits', 'qtype_numerical'),
+ 'menu' . $qa->get_qt_field_name('unit'), false, array('class' => 'accesshide'));
+ $unitchoice .= html_writer::select($question->ap->get_unit_options(),
$qa->get_qt_field_name('unit'), $selectedunit, array(''=>'choosedots'),
array('disabled' => $options->readonly));
}
View
4 question/type/shortanswer/renderer.php
@@ -71,8 +71,8 @@ public function formulation_and_controls(question_attempt $qa,
$placeholder = $matches[0];
$inputattributes['size'] = round(strlen($placeholder) * 1.1);
}
-
- $input = html_writer::empty_tag('input', $inputattributes) . $feedbackimg;
+ $input = html_writer::label($inputattributes['name'], $inputattributes['id'], false, array('class' => 'accesshide'));
+ $input .= html_writer::empty_tag('input', $inputattributes) . $feedbackimg;
if ($placeholder) {
$questiontext = substr_replace($questiontext, $input,

0 comments on commit daa3c5f

Please sign in to comment.