Skip to content

Commit cb07cc2

Browse files
tailetantai.letan
andauthored
Questionnaire\Accessibility\Numeric: Instructions not programmatically associated with field #672028 (#496)
Co-authored-by: tai.letan <[email protected]>
1 parent d27f42b commit cb07cc2

File tree

2 files changed

+50
-28
lines changed

2 files changed

+50
-28
lines changed

templates/question_numeric.mustache

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,37 @@
2929
3030
Example context (json):
3131
{
32-
"qelements": {
33-
"choice": {
34-
"onkeypress": "dosomething()",
35-
"size": 30,
36-
"name": "choiceid1",
37-
"maxlength": 50,
38-
"value": "473",
39-
"id": "choiceid1"
40-
}
41-
}
32+
"qelements": [
33+
{
34+
"choice": {
35+
"onkeypress": "dosomething()",
36+
"size": 30,
37+
"name": "choiceid1",
38+
"instruction": "Do not use thousands separators.",
39+
"maxlength": 50,
40+
"value": "473",
41+
"id": "choiceid1"
42+
}
43+
},
44+
{
45+
"choice": {
46+
"onkeypress": "dosomething()",
47+
"size": 20,
48+
"name": "choiceid2",
49+
"instruction": "Do not use thousands separators.",
50+
"maxlength": 50,
51+
"value": "473",
52+
"id": "choiceid2"
53+
}
54+
}
55+
]
4256
}
4357
}}
4458
<!-- Begin HTML generated from question_numeric template. -->
4559
{{#qelements}}
46-
{{#choice}}
47-
{{#instruction}}<span style="font-style: italic; font-size: 90%">{{.}}<br /></span>{{/instruction}}
48-
<input {{#choice.onkeypress}}onkeypress="{{.}}"{{/choice.onkeypress}} type="text" size="{{choice.size}}" name="{{choice.name}}" {{#choice.maxlength}}maxlength="{{choice.maxlength}}"{{/choice.maxlength}} value="{{choice.value}}" id="{{choice.id}}" />
49-
{{/choice}}
60+
{{#choice}}
61+
{{#instruction}}<span id="{{choice.id}}-instruction" style="font-style: italic; font-size: 90%">{{.}}<br /></span>{{/instruction}}
62+
<input {{#choice.onkeypress}}onkeypress="{{.}}"{{/choice.onkeypress}} aria-describedby="{{choice.id}}-instruction" type="text" size="{{choice.size}}" name="{{choice.name}}" {{#choice.maxlength}}maxlength="{{choice.maxlength}}"{{/choice.maxlength}} value="{{choice.value}}" id="{{choice.id}}" />
63+
{{/choice}}
5064
{{/qelements}}
5165
<!-- End HTML generated from question_numeric template. -->

tests/behat/numeric_question_digits.feature

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ Feature: Numeric questions can specify a maximum number of digits, and minimum n
66

77
Background: Add a numeric question to a questionnaire with a max digits and nb decimals specified
88
Given the following "users" exist:
9-
| username | firstname | lastname | email |
10-
| teacher1 | Teacher | 1 | teacher1@example.com |
11-
| student1 | Student | 1 | student1@example.com |
9+
| username | firstname | lastname | email |
10+
| teacher1 | Teacher | 1 | teacher1@example.com |
11+
| student1 | Student | 1 | student1@example.com |
1212
And the following "courses" exist:
1313
| fullname | shortname | category |
14-
| Course 1 | C1 | 0 |
14+
| Course 1 | C1 | 0 |
1515
And the following "course enrolments" exist:
16-
| user | course | role |
17-
| teacher1 | C1 | editingteacher |
18-
| student1 | C1 | student |
16+
| user | course | role |
17+
| teacher1 | C1 | editingteacher |
18+
| student1 | C1 | student |
1919
And the following "activities" exist:
20-
| activity | name | description | course | idnumber |
21-
| questionnaire | Test questionnaire | Test questionnaire description | C1 | questionnaire0 |
20+
| activity | name | description | course | idnumber |
21+
| questionnaire | Test questionnaire | Test questionnaire description | C1 | questionnaire0 |
2222
And I log in as "teacher1"
2323
And I am on "Course 1" course homepage
2424
And I follow "Test questionnaire"
2525
And I navigate to "Questions" in current page administration
2626
And I add a "Numeric" question and I fill the form with:
27-
| Question Name | Q1 |
28-
| Yes | y |
29-
| Max. digits allowed | 6 |
30-
| Nb of decimal digits | 2 |
31-
| Question Text | Enter no more than six digits including the decimal point |
27+
| Question Name | Q1 |
28+
| Yes | y |
29+
| Max. digits allowed | 6 |
30+
| Nb of decimal digits | 2 |
31+
| Question Text | Enter no more than six digits including the decimal point |
3232
Then I should see "position 1"
3333
And I should see "[Numeric] (Q1)"
3434
And I should see "Enter no more than six digits including the decimal point"
@@ -49,3 +49,11 @@ Feature: Numeric questions can specify a maximum number of digits, and minimum n
4949
And I should see "Test questionnaire"
5050
And I should see "Enter no more than six digits including the decimal point"
5151
And I should see "1.2345"
52+
53+
@javascript
54+
Scenario: Test question instruction accessibility.
55+
Given I am on the "Course 1" course page logged in as admin
56+
And I follow "Test questionnaire"
57+
When I navigate to "Answer the questions..." in current page administration
58+
Then "span[id^='numerical']" "css_element" should exist
59+
And "input[aria-describedby^='numerical']" "css_element" should exist

0 commit comments

Comments
 (0)