Skip to content

Commit 003d1d9

Browse files
Amir Qayyum khanamir-qayyum-khan
authored andcommitted
fix accessibility issues in code
1 parent 3f158db commit 003d1d9

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) {
@@ -169,10 +177,13 @@ function StaffGradedAssignmentXBlock(runtime, element) {
169177
event.preventDefault();
170178
if (isNaN(score)) {
171179
form.find('.error').html('<br/>Grade must be a number.');
180+
form.find('.error').focus();
172181
} else if (score !== parseInt(score)) {
173182
form.find('.error').html('<br/>Grade must be an integer.');
183+
form.find('.error').focus();
174184
} else if (score < 0) {
175185
form.find('.error').html('<br/>Grade must be positive.');
186+
form.find('.error').focus();
176187
} else if (score > max_score) {
177188
form.find('.error').html('<br/>Maximum score is ' + max_score);
178189
} 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

@@ -90,7 +91,7 @@
9091
</td>
9192
<td>
9293
<% if (assignment.may_grade) { %>
93-
<a class="enter-grade-button button" href="#{{ id }}-enter-grade">
94+
<a class="enter-grade-button button" href="#{{ id }}-enter-grade" role="button">
9495
<% if (assignment.needs_approval) { %>
9596
{% trans "Approve grade" %}
9697
<% } else { %>
@@ -100,7 +101,7 @@
100101
<% } %>
101102
</td>
102103
<td>
103-
<div class="upload">
104+
<div class="upload" aria-live="assertive" role="alert" tabindex="1">
104105
<input class="fileupload" type="file" name="annotated"/>
105106
<button>Upload annotated file</button>
106107
</div>
@@ -110,14 +111,14 @@
110111
</table>
111112
</script>
112113

113-
<div aria-hidden="true" class="wrap-instructor-info">
114+
<div class="wrap-instructor-info">
114115
<a class="instructor-info-action" id="grade-submissions-button"
115116
href="#{{ id }}-grade">{% trans "Grade Submissions" %}</a>
116117
<a class="instructor-info-action" id="staff-debug-info-button"
117118
href="#{{ id }}-debug">{% trans "Staff Debug Info" %}</a>
118119
</div>
119120

120-
<section aria-hidden="true" class="modal staff-modal" id="{{ id }}-grade" style="height: 75%">
121+
<section class="modal staff-modal" id="{{ id }}-grade" style="height: 75%">
121122
<div class="inner-wrapper" style="color: black; overflow: auto;">
122123
<header><h2><span class="display_name">{{ display_name }}</span> - {% trans "Staff Graded Assignment" %}</h2></header>
123124
<br/>
@@ -127,32 +128,32 @@
127128
</div>
128129
</section>
129130

130-
<section aria-hidden="true" class="modal staff-modal"
131+
<section class="modal staff-modal"
131132
style="height: 80%" id="{{ id }}-debug">
132133
<div class="inner-wrapper" style="color: black">
133-
<header><h2>{% trans "Staff Debug" %}</h2></header>
134+
<header role="banner"><h2>{% trans "Staff Debug" %}</h2></header>
134135
<br/>
135136
<div class="staff_info" style="display: block; white-space: normal">
136-
is_released = {{ is_released }}<br/>
137-
location = {{ location }}<br/>
137+
<span tabindex="1">is_released = {{ is_released }}</span> <br/>
138+
<span tabindex="1">location = {{ location }}</span><br/>
138139
<br/>
139140
<table summary="${_('Module Fields')}">
140-
<tr><th>{% trans "Module Fields" %}</th></tr>
141+
<tr><th tabindex="1">{% trans "Module Fields" %}</th></tr>
141142
{% for name, field in fields %}
142143
<tr>
143-
<td>{{name}}</td>
144+
<td tabindex="1">{{name}}</td>
144145
<td>
145-
<pre style="display:inline-block; margin: 0;">{{field}}</pre>
146+
<pre style="display:inline-block; margin: 0;" tabindex="1">{{field}}</pre>
146147
</td>
147148
</tr>
148149
{% endfor %}
149150
</table><br/>
150-
category = {{category}}
151+
<span tabindex="1">category = {{category}}</span>
151152
</div>
152153
</div>
153154
</section>
154155

155-
<section aria-hidden="true" class="modal grade-modal" id="{{ id }}-enter-grade">
156+
<section class="modal grade-modal" id="{{ id }}-enter-grade">
156157
<div class="inner-wrapper" style="color: black">
157158
<header><h2>
158159
{% trans "Enter Grade" %}
@@ -164,7 +165,7 @@
164165
<input id="submission_id-input" type="hidden" name="submission_id"/>
165166
<div>Grade for <span id="student-name"/></div>
166167
<div>Grade: <input id="grade-input" name="grade"/>
167-
<span class="error"></span></div>
168+
<span class="error" role="alert" aria-live="assertive" tabindex="1"></span></div>
168169
<div>Comment: <textarea id="comment-input" name="comment" rows="4"></textarea></div>
169170
<div>
170171
<button type="submit">{% trans "Submit" %}</button>

0 commit comments

Comments
 (0)