Skip to content

Commit d27f42b

Browse files
lamtranbemanoylovEmanoil Manoylovlamtranb
authored
Questionnaire\Accessibility\Rate: table does not have a programmatically associated caption (#497)
* Questionnaire: More meaningful error than nopermissions (#488) Co-authored-by: Emanoil Manoylov <[email protected]> * Questionnaire\Accessibility\Rate: table does not have a programmatically associated caption --------- Co-authored-by: emanoylov <[email protected]> Co-authored-by: Emanoil Manoylov <[email protected]> Co-authored-by: lamtranb <[email protected]>
1 parent f55147e commit d27f42b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

classes/question/rate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function get_feedback_maxscore() {
198198
protected function question_survey_display($response, $descendantsdata, $blankquestionnaire=false) {
199199
$choicetags = new \stdClass();
200200
$choicetags->qelements = [];
201+
$choicetags->qelements['caption'] = strip_tags($this->content);
201202

202203
$disabled = '';
203204
if ($blankquestionnaire) {

templates/question_rate.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
}
4747
]
4848
},
49+
"caption": "text",
4950
"rows": [
5051
{
5152
"cols": [
@@ -123,6 +124,7 @@
123124
<!-- Begin HTML generated from question_rate template. -->
124125
{{#qelements}}
125126
<table style="width:{{twidth}}">
127+
<caption class="accesshide">{{caption}}</caption>
126128
<tbody>
127129
{{#qelements.headerrow}}
128130
<tr>

tests/behat/rate_question_na.feature

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,41 @@ Feature: Rate scale questions have options for displaing "N/A"
6060
Then I should see "Test questionnaire"
6161
And I should see "Rate these movies from 1 to 5"
6262
And I should see "N/A"
63+
64+
@javascript
65+
Scenario: Test caption of table
66+
Given the following "users" exist:
67+
| username | firstname | lastname | email |
68+
| teacher1 | Teacher | 1 | [email protected] |
69+
| student1 | Student | 1 | [email protected] |
70+
And the following "courses" exist:
71+
| fullname | shortname | category |
72+
| Course 1 | C1 | 0 |
73+
And the following "course enrolments" exist:
74+
| user | course | role |
75+
| teacher1 | C1 | editingteacher |
76+
| student1 | C1 | student |
77+
And the following "activities" exist:
78+
| activity | name | description | course | idnumber |
79+
| questionnaire | Test questionnaire | Test questionnaire description | C1 | questionnaire0 |
80+
And I log in as "teacher1"
81+
And I am on "Course 1" course homepage
82+
And I follow "Test questionnaire"
83+
And I navigate to "Questions" in current page administration
84+
And I add a "Rate (scale 1..5)" question and I fill the form with:
85+
| Question Name | Q1 |
86+
| Yes | y |
87+
| Nb of scale items | 3 |
88+
| Type of rate scale | No duplicate choices |
89+
| Question Text | What are your top three movies? |
90+
| Possible answers | Star Wars,Casablanca,Airplane,Citizen Kane,Anchorman |
91+
Then I should see "position 1"
92+
And I should see "[Rate (scale 1..5)] (Q1)"
93+
And I should see "What are your top three movies?"
94+
And I log out
95+
96+
And I log in as "student1"
97+
And I am on "Course 1" course homepage
98+
And I follow "Test questionnaire"
99+
And I navigate to "Answer the questions..." in current page administration
100+
Then "//caption[@class='accesshide' and text()='What are your top three movies?']" "xpath_element" should exist

0 commit comments

Comments
 (0)