Skip to content

Commit

Permalink
MDL-67663 mod_forum: Make user switching more accessible
Browse files Browse the repository at this point in the history
* Add a more descriptive label for the next and previous buttons so that
the users would know that clicking on the next or previous buttons will
save the changes they made before proceeding to the next user.
* Add an sr-only div with aria-live to the user picker to let the grader
know the current user that is being graded.
* Hide the user picture from screen readers
  • Loading branch information
junpataleta committed Apr 9, 2020
1 parent 49f07dc commit 79d668f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions mod/forum/amd/src/local/grades/local/grader/user_picker.js
Expand Up @@ -24,6 +24,7 @@

import Templates from 'core/templates';
import Selectors from './user_picker/selectors';
import {get_string as getString} from 'core/str';

const templatePath = 'mod_forum/local/grades/local/grader';

Expand Down Expand Up @@ -111,6 +112,10 @@ class UserPicker {
const [{html, js}] = await Promise.all([this.renderUserChange(user), this.showUserCallback(user)]);
const userRegion = this.root.querySelector(Selectors.regions.userRegion);
Templates.replaceNodeContents(userRegion, html, js);

// Update the hidden now-grading region so screen readers can announce the user that's currently being graded.
const currentUserRegion = this.root.querySelector(Selectors.regions.currentUser);
currentUserRegion.textContent = await getString('nowgradinguser', 'mod_forum', user.fullname);
}

/**
Expand Down
Expand Up @@ -24,6 +24,7 @@

export default {
regions: {
currentUser: '[data-region="user_picker/current_user"]',
userRegion: '[data-region="user_picker/user"]',
},
actions: {
Expand Down
5 changes: 3 additions & 2 deletions mod/forum/lang/en/forum.php
Expand Up @@ -443,7 +443,7 @@
$string['namesocial'] = 'Social forum';
$string['nameteacher'] = 'Teacher forum';
$string['nextdiscussiona'] = 'Next discussion: {$a}';
$string['nextuser'] = 'Next user';
$string['nextuser'] = 'Save changes and proceed to the next user';
$string['newforumposts'] = 'New forum posts';
$string['noattachments'] = 'There are no attachments to this post';
$string['nodiscussions'] = 'There are no discussion topics yet in this forum';
Expand Down Expand Up @@ -522,7 +522,7 @@
$string['posttoforum'] = 'Post to forum';
$string['postupdated'] = 'Your post was updated';
$string['potentialsubscribers'] = 'Potential subscribers';
$string['previoususer'] = 'Previous user';
$string['previoususer'] = 'Save changes and proceed to the previous user';
$string['privacy:digesttypenone'] = 'We do not hold any data relating to a preferred forum digest type for this forum.';
$string['privacy:digesttypepreference'] = 'You have chosen to receive the following forum digest type: "{$a->type}".';
$string['privacy:discussionsubscriptionpreference'] = 'You have chosen the following discussion subscription preference for this forum: "{$a->preference}"';
Expand Down Expand Up @@ -748,6 +748,7 @@
$string['grade_rating_name'] = 'Rating';
$string['gradeusers'] = 'Grade users';
$string['graded'] = 'Graded';
$string['nowgradinguser'] = 'Now grading {$a}';
$string['gradeforrating'] = 'Grade for rating: {$a->str_long_grade}';
$string['gradeforratinghidden'] = 'Grade for rating hidden';
$string['gradeforwholeforum'] = 'Grade for forum: {$a->str_long_grade}';
Expand Down
Expand Up @@ -36,35 +36,36 @@
}}

<div class="d-flex align-items-center user-picker-container mb-2 py-2">
<div aria-live="polite" data-region="user_picker/current_user" class="sr-only"></div>
<div class="d-flex align-items-center" data-region="user_picker/user"></div>
<div class="ml-auto flex-shrink-0">
<nav aria-label="{{#str}} usernavigation, mod_forum {{/str}}">
<ul class="pagination mb-0">
<li class="page-item">
<a
<button
class="page-link icon-no-margin p-0 text-reset icon-size-3"
href="#"
aria-label="{{#str}} previous {{/str}}"
aria-label="{{#str}} previoususer, mod_forum {{/str}}"
data-action="change-user"
data-direction="-1"
title="{{#str}} previoususer, mod_forum {{/str}}"
>
<span class="dir-ltr-hide">{{#pix}} i/next, core {{/pix}}</span>
<span class="dir-rtl-hide">{{#pix}} i/previous, core {{/pix}}</span>
</a>
</button>
</li>
<li class="page-item">
<a
<button
class="page-link icon-no-margin p-0 text-reset icon-size-3 ml-2"
href="#"
aria-label="{{#str}} next {{/str}}"
aria-label="{{#str}} nextuser, mod_forum {{/str}}"
data-action="change-user"
data-direction="1"
title="{{#str}} nextuser, mod_forum {{/str}}"
>
<span class="dir-ltr-hide">{{#pix}} i/previous, core {{/pix}}</span>
<span class="dir-rtl-hide">{{#pix}} i/next, core {{/pix}}</span>
</a>
</button>
</li>
</ul>
</nav>
Expand Down
Expand Up @@ -42,8 +42,7 @@
<img
class="rounded-circle userpicture mr-2"
src="{{.}}"
alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
title="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
aria-hidden="true"
>
{{/profileimage}}
<div>
Expand Down

0 comments on commit 79d668f

Please sign in to comment.