From 97cf42e0ef4ce7ffdee36d771bfb7dee3da50dde Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Fri, 3 Apr 2020 20:00:52 +1100 Subject: [PATCH] MDL-68312 grade: Fix empty links If a link contains no text, the function or purpose of the link will not be presented to the user. This can introduce confusion for keyboard and screen reader users. --- grade/report/grader/lib.php | 29 ++++++++++++++++++++--------- grade/report/lib.php | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index e0be4356c1c..193bffee72e 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -751,13 +751,18 @@ class grade_report_grader extends grade_report { $a = new stdClass(); $a->user = $fullname; $strgradesforuser = get_string('gradesforuser', 'grades', $a); - $url = new moodle_url('/grade/report/'.$CFG->grade_profilereport.'/index.php', array('userid' => $user->id, 'id' => $this->course->id)); - $userreportcell->text .= $OUTPUT->action_icon($url, new pix_icon('t/grades', $strgradesforuser)); + $url = new moodle_url('/grade/report/'.$CFG->grade_profilereport.'/index.php', + ['userid' => $user->id, 'id' => $this->course->id]); + $userreportcell->text .= $OUTPUT->action_icon($url, new pix_icon('t/grades', ''), null, + ['title' => $strgradesforuser, 'aria-label' => $strgradesforuser]); } if ($canseesingleview) { - $url = new moodle_url('/grade/report/singleview/index.php', array('id' => $this->course->id, 'itemid' => $user->id, 'item' => 'user')); - $singleview = $OUTPUT->action_icon($url, new pix_icon('t/editstring', get_string('singleview', 'grades', $fullname))); + $strsingleview = get_string('singleview', 'grades', $fullname); + $url = new moodle_url('/grade/report/singleview/index.php', + ['id' => $this->course->id, 'itemid' => $user->id, 'item' => 'user']); + $singleview = $OUTPUT->action_icon($url, new pix_icon('t/editstring', ''), null, + ['title' => $strsingleview, 'aria-label' => $strsingleview]); $userreportcell->text .= $singleview; } @@ -911,13 +916,16 @@ class grade_report_grader extends grade_report { if (has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', 'moodle/grade:edit'), $this->context)) { + $strsingleview = get_string('singleview', 'grades', $element['object']->get_name()); $url = new moodle_url('/grade/report/singleview/index.php', array( 'id' => $this->course->id, 'item' => 'grade', 'itemid' => $element['object']->id)); $singleview = $OUTPUT->action_icon( - $url, - new pix_icon('t/editstring', get_string('singleview', 'grades', $element['object']->get_name())) + $url, + new pix_icon('t/editstring', ''), + null, + ['title' => $strsingleview, 'aria-label' => $strsingleview] ); } } @@ -1636,15 +1644,18 @@ class grade_report_grader extends grade_report { if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) { $url->param('action', 'switch_plus'); - $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_plus', $strswitchplus), null, null); + $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_plus', ''), null, + ['title' => $strswitchplus, 'aria-label' => $strswitchplus]); $showing = get_string('showingaggregatesonly', 'grades'); } else if (in_array($element['object']->id, $this->collapsed['gradesonly'])) { $url->param('action', 'switch_whole'); - $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_whole', $strswitchwhole), null, null); + $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_whole', ''), null, + ['title' => $strswitchwhole, 'aria-label' => $strswitchwhole]); $showing = get_string('showinggradesonly', 'grades'); } else { $url->param('action', 'switch_minus'); - $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_minus', $strswitchminus), null, null); + $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_minus', ''), null, + ['title' => $strswitchminus, 'aria-label' => $strswitchminus]); $showing = get_string('showingfullmode', 'grades'); } } diff --git a/grade/report/lib.php b/grade/report/lib.php index 70be5da30a1..8df63248ff7 100644 --- a/grade/report/lib.php +++ b/grade/report/lib.php @@ -417,8 +417,8 @@ abstract class grade_report { $matrix = array('up' => 'desc', 'down' => 'asc', 'move' => 'desc'); $strsort = $this->get_lang_string('sort' . $matrix[$direction]); - $arrow = $OUTPUT->pix_icon($pix[$direction], $strsort, '', array('class' => 'sorticon')); - return html_writer::link($sortlink, $arrow, array('title'=>$strsort)); + $arrow = $OUTPUT->pix_icon($pix[$direction], '', '', ['class' => 'sorticon']); + return html_writer::link($sortlink, $arrow, ['title' => $strsort, 'aria-label' => $strsort]); } /**