Skip to content

Commit 2376229

Browse files
committed
MDL-85902 course: Better labeling of activity navigation components
* The arrow icons produced by the `$OUTPUT->larrow()` and `$OUTPUT->rarrow()` functions are announced by screen readers, and they do not make sense when heard by screen reader users. To fix this, we need to override the accessible names of the previous and next activity links using the `aria-label` attribute and specify whether the activity links point to the previous or next activities. * The label for the jump menu "Jump to" is not informative enough to convey the element's purpose. Let's improve it's accessible label to "Jump to activity".
1 parent 34e8a6f commit 2376229

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

course/classes/output/activity_navigation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function __construct($prevmod, $nextmod, $activitylist = array()) {
7474
$attributes = [
7575
'class' => 'btn btn-link',
7676
'id' => 'prev-activity-link',
77+
'aria-label' => get_string('activitynavigation:preva', 'course', $linkname),
7778
];
7879
$this->prevlink = new \action_link($linkurl, $OUTPUT->larrow() . ' ' . $linkname, null, $attributes);
7980
}
@@ -89,14 +90,15 @@ public function __construct($prevmod, $nextmod, $activitylist = array()) {
8990
$attributes = [
9091
'class' => 'btn btn-link',
9192
'id' => 'next-activity-link',
93+
'aria-label' => get_string('activitynavigation:nexta', 'course', $linkname),
9294
];
9395
$this->nextlink = new \action_link($linkurl, $linkname . ' ' . $OUTPUT->rarrow(), null, $attributes);
9496
}
9597

9698
// Render the activity list dropdown menu if available.
9799
if (!empty($activitylist)) {
98-
$select = new url_select($activitylist, '', array('' => get_string('jumpto')));
99-
$select->set_label(get_string('jumpto'), array('class' => 'sr-only'));
100+
$select = new url_select($activitylist, '', array('' => get_string('activitynavigation:jumptoactivity', 'course')));
101+
$select->set_label(get_string('activitynavigation:jumptoactivity', 'course'), ['class' => 'sr-only']);
100102
$select->attributes = array('id' => 'jump-to-activity');
101103
$this->activitylist = $select;
102104
}

lang/en/course.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
$string['activitydate:opened'] = 'Opened:';
4242
$string['activitydate:opens'] = 'Opens:';
4343
$string['activitynavigation'] = 'Activity navigation';
44+
$string['activitynavigation:nexta'] = 'Next activity: {$a}';
45+
$string['activitynavigation:preva'] = 'Previous activity: {$a}';
46+
$string['activitynavigation:jumptoactivity'] = 'Jump to activity';
4447
$string['aria:coursecategory'] = 'Course category';
4548
$string['aria:courseshortname'] = 'Course short name';
4649
$string['aria:coursename'] = 'Course name';

0 commit comments

Comments
 (0)