Skip to content

Commit

Permalink
MDL-47310 gradebook: accessibility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jetha Chan committed Oct 30, 2014
1 parent b7ff403 commit 43cd76e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
15 changes: 7 additions & 8 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1351,15 +1351,14 @@ public function get_element_header(&$element, $withlink=false, $icon=true, $spac
return $header;
}

if ($withlink) {
$url = $this->get_activity_link($element);
if ($url) {
$a = new stdClass();
$a->name = get_string('modulename', $element['object']->itemmodule);
$title = get_string('linktoactivity', 'grades', $a);
if ($withlink && $url = $this->get_activity_link($element)) {
$a = new stdClass();
$a->name = get_string('modulename', $element['object']->itemmodule);
$title = get_string('linktoactivity', 'grades', $a);

$header = html_writer::link($url, $header, array('title' => $title));
}
$header = html_writer::link($url, $header, array('title' => $title));
} else {
$header = html_writer::span($header);
}

if ($withdescription) {
Expand Down
33 changes: 30 additions & 3 deletions grade/report/singleview/classes/local/screen/grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public function init($selfitemisempty = false) {
public function original_headers() {
return array(
'', // For filter icon.
'', // For user picture.
get_string('firstname') . ' (' . get_string('alternatename') . ') ' . get_string('lastname'),
get_string('range', 'grades'),
get_string('grade', 'grades'),
Expand Down Expand Up @@ -208,12 +207,31 @@ public function format_line($item) {

$line = array(
$OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', $iconstring)),
$OUTPUT->user_picture($item),
$OUTPUT->user_picture($item, array('visibletoscreenreaders' => false)) .
html_writer::link($url, $fullname),
$this->item_range()
);
$lineclasses = array(
"action",
"user",
"range"
);
$outputline = array();
$i = 0;
foreach ($line as $key => $value) {
$cell = new \html_table_cell($value);
if ($isheader = $i == 1) {
$cell->header = $isheader;
$cell->scope = "row";
}
if (array_key_exists($key, $lineclasses)) {
$cell->attributes['class'] = $lineclasses[$key];
}
$outputline[] = $cell;
$i++;
}

return $this->format_definition($line, $grade);
return $this->format_definition($outputline, $grade);
}

/**
Expand Down Expand Up @@ -267,6 +285,15 @@ public function heading() {
return $this->item->get_name();
}

/**
* Get the summary for this table.
*
* @return string
*/
public function summary() {
return get_string('summarygrade', 'gradereport_singleview');
}

/**
* Process the data from the form.
*
Expand Down
12 changes: 12 additions & 0 deletions grade/report/singleview/classes/local/screen/tablelike.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ abstract class tablelike extends screen {
*/
public abstract function format_line($item);

/**
* Get the summary for this table.
*
* @return string
*/
public abstract function summary();

/**
* Get the table headers
*
Expand Down Expand Up @@ -166,6 +173,11 @@ public function html() {

$table->head = $this->headers();

$summary = $this->summary();
if (!empty($summary)) {
$table->summary = $summary;
}

// To be used for extra formatting.
$this->index = 0;
$this->total = count($this->items);
Expand Down
38 changes: 35 additions & 3 deletions grade/report/singleview/classes/local/screen/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public function init($selfitemisempty = false) {
public function original_headers() {
return array(
'', // For filter icon.
'', // For activity icon.
get_string('assessmentname', 'gradereport_singleview'),
get_string('gradecategory', 'grades'),
get_string('range', 'grades'),
Expand Down Expand Up @@ -197,9 +196,33 @@ public function format_line($item) {

$line = array(
$OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', $iconstring)),
$this->format_icon($item) . $lockicon, $itemlabel, $this->category($item), (new range($item))
$this->format_icon($item) . $lockicon . $itemlabel,
$this->category($item),
new range($item)
);
return $this->format_definition($line, $grade);
$lineclasses = array(
"action",
"gradeitem",
"category",
"range"
);

$outputline = array();
$i = 0;
foreach ($line as $key => $value) {
$cell = new \html_table_cell($value);
if ($isheader = $i == 1) {
$cell->header = $isheader;
$cell->scope = "row";
}
if (array_key_exists($key, $lineclasses)) {
$cell->attributes['class'] = $lineclasses[$key];
}
$outputline[] = $cell;
$i++;
}

return $this->format_definition($outputline, $grade);
}

/**
Expand Down Expand Up @@ -252,6 +275,15 @@ public function heading() {
return fullname($this->item);
}

/**
* Get the summary for this table.
*
* @return string
*/
public function summary() {
return get_string('summaryuser', 'gradereport_singleview');
}

/**
* Default pager
*
Expand Down
2 changes: 2 additions & 0 deletions grade/report/singleview/lang/en/gradereport_singleview.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
$string['overridenone'] = 'Override no grades';
$string['pluginname'] = 'Single view';
$string['singleview:view'] = 'View report';
$string['summarygrade'] = 'A table of users, with columns for range, grade, feedback, and whether to override or exclude a particular grade.';
$string['summaryuser'] = 'A table of grade items, with columns for grade category, range, grade, feedback, and whether to override or exclude a particular grade.';
8 changes: 8 additions & 0 deletions grade/report/singleview/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
.path-grade-report-singleview input[name^="finalgrade"] {
width: 50px;
}
.path-grade-report-singleview .generaltable tbody th {
white-space: nowrap;
}
.path-grade-report-singleview .generaltable tbody th > * {
display: inline-block;
vertical-align: middle;
margin: 0 2px;
}

.path-grade-report-singleview #region-main h2, .paging{
text-align: center;
Expand Down

0 comments on commit 43cd76e

Please sign in to comment.