Skip to content

Commit f4bddb0

Browse files
Amir Qayyum khanamir-qayyum-khan
authored andcommitted
fix accessibility issues in code
1 parent 27f5457 commit f4bddb0

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

edx_sga/static/js/src/edx_sga.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ function StaffGradedAssignmentXBlock(runtime, element) {
4848
return;
4949
}
5050
}
51+
var uploadElement = $(content).find(".upload");
52+
uploadElement.attr("role", "progressbar");
53+
uploadElement.attr("aria-valuemax", "100");
54+
uploadElement.attr("aria-valuemin", "0");
5155
data.submit();
5256
});
5357
},
5458
progressall: function(e, data) {
5559
var percent = parseInt(data.loaded / data.total * 100, 10);
56-
$(content).find('.upload').text(
57-
'Uploading... ' + percent + '%');
60+
var uploadElement = $(content).find(".upload");
61+
uploadElement.text("Uploading... " + percent + "%");
62+
uploadElement.attr("aria-valuenow" , percent);
63+
uploadElement.attr("aria-valuetext" , "Uploading... " + percent + "%");
5864
},
5965
fail: function(e, data) {
6066
/**
@@ -100,8 +106,10 @@ function StaffGradedAssignmentXBlock(runtime, element) {
100106
}
101107
}
102108
});
103-
104109
updateChangeEvent(fileUpload);
110+
if (!_.isUndefined(state.error)) {
111+
$(content).find('p.error').focus();
112+
}
105113
}
106114

107115
function renderStaffGrading(data) {
@@ -198,10 +206,13 @@ function StaffGradedAssignmentXBlock(runtime, element) {
198206
event.preventDefault();
199207
if (isNaN(score)) {
200208
form.find('.error').html('<br/>Grade must be a number.');
209+
form.find('.error').focus();
201210
} else if (score !== parseInt(score)) {
202211
form.find('.error').html('<br/>Grade must be an integer.');
212+
form.find('.error').focus();
203213
} else if (score < 0) {
204214
form.find('.error').html('<br/>Grade must be positive.');
215+
form.find('.error').focus();
205216
} else if (score > max_score) {
206217
form.find('.error').html('<br/>Maximum score is ' + max_score);
207218
} else {
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{% load i18n %}
22

3-
<div id="staff-graded-assignment-edit">
4-
<ul class="list-input settings-list">
3+
<div id="staff-graded-assignment-edit" role="form">
4+
<div class="list-input settings-list">
55
{% for field, value, validator in fields %}
6-
<li class="field comp-setting-entry metadata_entry">
6+
<div class="field comp-setting-entry metadata_entry">
77
<div class="wrapper-comp-setting">
8-
<label class="label setting-label"
8+
<label class="label setting-label"
99
for="{{ field.name }}_input">{{ field.display_name }}</label>
10-
<input class="input setting-input" type="text"
11-
id="{{ field.name }}_input" name="{{ field.name}}"
10+
<input class="input setting-input" type="text" aria-describedby="{{ field.name }}_hint"
11+
id="{{ field.name }}_input" name="{{ field.name}}"
1212
value="{{ value }}" data-validator="{{ validator }}"/>
1313
</div>
14-
<span class="tip setting-help">{{ field.help }}</span>
15-
</li>
14+
<span id="{{ field.name }}_hint" class="tip setting-help">{{ field.help }}</span>
15+
</div>
1616
{% endfor %}
17-
</ul>
17+
</div>
1818
</div>
1919

2020
<script type="application/javascript">
21-
$("ul.action-modes").html(' <li class="view-button sga_editor_tab">{% trans "Settings" %}</li>')
21+
$("ul.action-modes").html(' <li class="view-button sga_editor_tab" aria-label="settings">{% trans "Settings" %}</li>')
22+
$("h2.modal-window-title").attr("tabindex","0");
2223
</script>

edx_sga/templates/staff_graded_assignment/show.html

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{% load i18n %}
22

33
<div class="sga-block" data-state="{{ student_state }}" data-max-size="{{ max_file_size }}"
4-
data-staff="{{ is_course_staff }}">
4+
data-staff="{{ is_course_staff }}" role="article" aria-describedby="title">
55
<script type="text/template" id="sga-tmpl">
66
<% if (display_name) { %>
7-
<b><%= display_name %></b>
7+
<b id="title"><%= display_name %></b>
88
<% } %>
99
<% if (uploaded) { %>
10-
<p><b>File uploaded</b>
11-
<a href="<%= downloadUrl %>"><%= uploaded.filename %></a></p>
10+
<br/>
11+
<label for="file_uploaded"><b>File uploaded</b></label>
12+
<a href="<%= downloadUrl %>" role="link" id="file_uploaded"><%= uploaded.filename %></a>
1213
<% } else { %>
1314
<p>No file has been uploaded.</p>
1415
<% } %>
@@ -18,28 +19,28 @@
1819
<b>Instructor comment</b> <%= graded.comment %>
1920
<% } %>
2021
<% if (annotated) { %><br/>
21-
<b>Annotated file from instructor</b>
22-
<a href="<%= annotatedUrl %>"><%= annotated.filename %></a>
22+
<b id="annotated_file">Annotated file from instructor</b>
23+
<a href="<%= annotatedUrl %>" aria-describedby="annotated_file"><%= annotated.filename %></a>
2324
<% } %>
2425
</p>
2526
<% } else if (uploaded) { %>
26-
{% trans "This assignment has not yet been graded." %}
27+
<p>{% trans "This assignment has not yet been graded." %}</p>
2728
<% } %>
2829
<% if (upload_allowed) { %>
2930
<p>
3031
<% if (uploaded) { %>
31-
{% trans "Upload a different file" %}
32+
<span id="upload_label">{% trans "Upload a different file" %}</span>
3233
<% } else { %>
33-
{% trans "Upload your assignment" %}
34+
<span id="upload_label">{% trans "Upload your assignment" %}</span>
3435
<% } %>
35-
<div class="upload">
36+
<div class="upload" aria-describedby="upload_label" role="alert" aria-live="assertive" tabindex="1">
3637
<input class="fileupload" type="file" name="assignment"/>
3738
<button>Select a file</button>
3839
</div>
3940
</p>
4041
<% } %>
4142
<% if (error) { %>
42-
<p class="error"><%= error %></p>
43+
<p class="error" role="alert" aria-live="assertive" tabindex="1"><%= error %></p>
4344
<% } %>
4445
</script>
4546

@@ -93,7 +94,7 @@
9394
</td>
9495
<td>
9596
<% if (assignment.may_grade) { %>
96-
<a class="enter-grade-button button" href="#{{ id }}-enter-grade">
97+
<a class="enter-grade-button button" href="#{{ id }}-enter-grade" role="button">
9798
<% if (assignment.needs_approval) { %>
9899
{% trans "Approve grade" %}
99100
<% } else { %>
@@ -103,7 +104,7 @@
103104
<% } %>
104105
</td>
105106
<td>
106-
<div class="upload">
107+
<div class="upload" aria-live="assertive" role="alert" tabindex="1">
107108
<input class="fileupload" type="file" name="annotated"/>
108109
<button>Upload annotated file</button>
109110
</div>
@@ -114,14 +115,14 @@
114115
</table>
115116
</script>
116117

117-
<div aria-hidden="true" class="wrap-instructor-info">
118+
<div class="wrap-instructor-info">
118119
<a class="instructor-info-action" id="grade-submissions-button"
119120
href="#{{ id }}-grade">{% trans "Grade Submissions" %}</a>
120121
<a class="instructor-info-action" id="staff-debug-info-button"
121122
href="#{{ id }}-debug">{% trans "Staff Debug Info" %}</a>
122123
</div>
123124

124-
<section aria-hidden="true" class="modal staff-modal" id="{{ id }}-grade" style="height: 75%">
125+
<section class="modal staff-modal" id="{{ id }}-grade" style="height: 75%">
125126
<div class="inner-wrapper" style="color: black; overflow: auto;">
126127
<header><h2><span class="display_name">{{ display_name }}</span> - {% trans "Staff Graded Assignment" %}</h2></header>
127128
<br/>
@@ -131,32 +132,32 @@
131132
</div>
132133
</section>
133134

134-
<section aria-hidden="true" class="modal staff-modal"
135+
<section class="modal staff-modal"
135136
style="height: 80%" id="{{ id }}-debug">
136137
<div class="inner-wrapper" style="color: black">
137-
<header><h2>{% trans "Staff Debug" %}</h2></header>
138+
<header role="banner"><h2>{% trans "Staff Debug" %}</h2></header>
138139
<br/>
139140
<div class="staff_info" style="display: block; white-space: normal">
140-
is_released = {{ is_released }}<br/>
141-
location = {{ location }}<br/>
141+
<span tabindex="1">is_released = {{ is_released }}</span> <br/>
142+
<span tabindex="1">location = {{ location }}</span><br/>
142143
<br/>
143144
<table summary="${_('Module Fields')}">
144-
<tr><th>{% trans "Module Fields" %}</th></tr>
145+
<tr><th tabindex="1">{% trans "Module Fields" %}</th></tr>
145146
{% for name, field in fields %}
146147
<tr>
147-
<td>{{name}}</td>
148+
<td tabindex="1">{{name}}</td>
148149
<td>
149-
<pre style="display:inline-block; margin: 0;">{{field}}</pre>
150+
<pre style="display:inline-block; margin: 0;" tabindex="1">{{field}}</pre>
150151
</td>
151152
</tr>
152153
{% endfor %}
153154
</table><br/>
154-
category = {{category}}
155+
<span tabindex="1">category = {{category}}</span>
155156
</div>
156157
</div>
157158
</section>
158159

159-
<section aria-hidden="true" class="modal grade-modal" id="{{ id }}-enter-grade">
160+
<section class="modal grade-modal" id="{{ id }}-enter-grade">
160161
<div class="inner-wrapper" style="color: black">
161162
<header><h2>
162163
{% trans "Enter Grade" %}
@@ -168,7 +169,7 @@
168169
<input id="submission_id-input" type="hidden" name="submission_id"/>
169170
<div>Grade for <span id="student-name"/></div>
170171
<div>Grade: <input id="grade-input" name="grade"/>
171-
<span class="error"></span></div>
172+
<span class="error" role="alert" aria-live="assertive" tabindex="1"></span></div>
172173
<div>Comment: <textarea id="comment-input" name="comment" rows="4"></textarea></div>
173174
<div>
174175
<button type="submit">{% trans "Submit" %}</button>

0 commit comments

Comments
 (0)