From 10bc73d5b6d5e6091d6332734dca52fbc1cd1354 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 6 Apr 2020 17:03:51 +1000 Subject: [PATCH 1/5] MDL-68343 output: fix html table structure A that contains no text may result in cells with missing or incorrect header information. WAVE advises that we should make a cell a rather than a if the cell must remain empty (such as the top-left cell in a data table). Also note that the scope attribute is only valid for --- lib/outputcomponents.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index ab3f3e4833e..6b7654c0c58 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -2207,8 +2207,9 @@ class html_writer { $heading->header = true; } - if ($heading->header && empty($heading->scope)) { - $heading->scope = 'col'; + $tagtype = 'td'; + if ($heading->header && (string)$heading->text != '') { + $tagtype = 'th'; } $heading->attributes['class'] .= ' header c' . $key; @@ -2224,16 +2225,15 @@ class html_writer { $heading->attributes['class'] .= ' ' . $table->colclasses[$key]; } $heading->attributes['class'] = trim($heading->attributes['class']); - $attributes = array_merge($heading->attributes, array( - 'style' => $table->align[$key] . $table->size[$key] . $heading->style, - 'scope' => $heading->scope, - 'colspan' => $heading->colspan, - )); + $attributes = array_merge($heading->attributes, [ + 'style' => $table->align[$key] . $table->size[$key] . $heading->style, + 'colspan' => $heading->colspan, + ]); - $tagtype = 'td'; - if ($heading->header === true) { - $tagtype = 'th'; + if ($tagtype == 'th') { + $attributes['scope'] = !empty($heading->scope) ? $heading->scope : 'col'; } + $output .= html_writer::tag($tagtype, $heading->text, $attributes) . "\n"; } $output .= html_writer::end_tag('tr') . "\n"; From 5d2be187a28943a3cef3a3a4be1be5aacada130f Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 6 Apr 2020 17:05:14 +1000 Subject: [PATCH 2/5] MDL-68343 gradereport_singleview: Only output label tag if label exists This also fixes the issue of having multiple form labels for a single element. --- grade/report/singleview/templates/text_attribute.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grade/report/singleview/templates/text_attribute.mustache b/grade/report/singleview/templates/text_attribute.mustache index 6c73b9cf6b9..47a1ae34b10 100644 --- a/grade/report/singleview/templates/text_attribute.mustache +++ b/grade/report/singleview/templates/text_attribute.mustache @@ -28,6 +28,6 @@ "disabled": "true" } }} - +{{#label}}{{/label}} From cc36c39b468295a600fad64e8c7097a1e008b6bd Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 6 Apr 2020 18:11:21 +1000 Subject: [PATCH 3/5] MDL-68343 gradereport_singleview: fix empty links --- grade/lib.php | 5 +++-- grade/report/singleview/classes/local/screen/grade.php | 3 ++- grade/report/singleview/classes/local/screen/user.php | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index 67857cb02fa..2e8c8d33d1b 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -1791,8 +1791,9 @@ class grade_structure { return ''; } - return $OUTPUT->action_icon($url, new pix_icon('t/preview', - get_string('gradeanalysis', 'core_grades'))); + $title = get_string('gradeanalysis', 'core_grades'); + return $OUTPUT->action_icon($url, new pix_icon('t/preview', ''), null, + ['title' => $title, 'aria-label' => $title]); } /** diff --git a/grade/report/singleview/classes/local/screen/grade.php b/grade/report/singleview/classes/local/screen/grade.php index ddebda79b55..7d86723e307 100644 --- a/grade/report/singleview/classes/local/screen/grade.php +++ b/grade/report/singleview/classes/local/screen/grade.php @@ -210,7 +210,8 @@ class grade extends tablelike implements selectable_items, filterable_items { $grade->label = $fullname; $line = array( - $OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', $iconstring)), + $OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', ''), null, + ['title' => $iconstring, 'aria-label' => $iconstring]), $OUTPUT->user_picture($item, array('visibletoscreenreaders' => false)) . html_writer::link($url, $fullname), $this->item_range() diff --git a/grade/report/singleview/classes/local/screen/user.php b/grade/report/singleview/classes/local/screen/user.php index 3043a8694a9..3e90a88b771 100644 --- a/grade/report/singleview/classes/local/screen/user.php +++ b/grade/report/singleview/classes/local/screen/user.php @@ -190,7 +190,8 @@ class user extends tablelike implements selectable_items { $grade->label = $item->get_name(); $line = array( - $OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', $iconstring)), + $OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', ''), null, + ['title' => $iconstring, 'aria-label' => $iconstring]), $this->format_icon($item) . $lockicon . $itemlabel, $this->category($item), new range($item) From 85bf5b2e2ca72e9f449bea8e99cdc93a0ad77a61 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 6 Apr 2020 18:32:16 +1000 Subject: [PATCH 4/5] MDL-68343 gradereport_singleview: Use caption instead of summary The summary attribute on the table element is obsolete. --- grade/report/singleview/classes/local/screen/tablelike.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grade/report/singleview/classes/local/screen/tablelike.php b/grade/report/singleview/classes/local/screen/tablelike.php index 9c5f025315b..3498fe4a804 100644 --- a/grade/report/singleview/classes/local/screen/tablelike.php +++ b/grade/report/singleview/classes/local/screen/tablelike.php @@ -172,7 +172,8 @@ abstract class tablelike extends screen { $summary = $this->summary(); if (!empty($summary)) { - $table->summary = $summary; + $table->caption = $summary; + $table->captionhide = true; } // To be used for extra formatting. From f9b144d6bf61d7cd828b610c5c75d1110fb308c0 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 6 Apr 2020 19:23:54 +1000 Subject: [PATCH 5/5] MDL-68343 gradereport_singleview: Remove adjacent links to the same URL --- grade/report/singleview/classes/local/screen/grade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grade/report/singleview/classes/local/screen/grade.php b/grade/report/singleview/classes/local/screen/grade.php index 7d86723e307..f3b4ad7e72c 100644 --- a/grade/report/singleview/classes/local/screen/grade.php +++ b/grade/report/singleview/classes/local/screen/grade.php @@ -208,12 +208,12 @@ class grade extends tablelike implements selectable_items, filterable_items { $url = new moodle_url("/user/view.php", array('id' => $item->id, 'course' => $this->courseid)); $iconstring = get_string('filtergrades', 'gradereport_singleview', $fullname); $grade->label = $fullname; + $userpic = $OUTPUT->user_picture($item, ['link' => false, 'visibletoscreenreaders' => false]); $line = array( $OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', ''), null, ['title' => $iconstring, 'aria-label' => $iconstring]), - $OUTPUT->user_picture($item, array('visibletoscreenreaders' => false)) . - html_writer::link($url, $fullname), + html_writer::link($url, $userpic . $fullname), $this->item_range() ); $lineclasses = array(