Browse files

MDL-30852 grade report: Add aria attributes

Converted to git branch by Damyon
  • Loading branch information...
1 parent a9657ad commit 95ad1cee1276c04dd2b94054d4bab99698306430 @smbader smbader committed with damyon Aug 2, 2013
Showing with 60 additions and 19 deletions.
  1. +1 −0 grade/report/user/lang/en/gradereport_user.php
  2. +23 −4 grade/report/user/lib.php
  3. +36 −15 grade/report/user/styles.css
View
1 grade/report/user/lang/en/gradereport_user.php
@@ -24,3 +24,4 @@
$string['pluginname'] = 'User report';
$string['user:view'] = 'View your own grade report';
+$string['tablesummary'] = 'The table is arranged as a list of graded items including categories of graded items. When items are in a category they will be indicated as such.';
View
27 grade/report/user/lib.php
@@ -337,6 +337,9 @@ private function fill_table_recursive(&$element) {
/// Process those items that have scores associated
if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
+ $header_row = "row_{$eid}_{$this->user->id}";
+ $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
+
if (! $grade_grade = grade_grade::fetch(array('itemid'=>$grade_object->id,'userid'=>$this->user->id))) {
$grade_grade = new grade_grade();
$grade_grade->userid = $this->user->id;
@@ -387,11 +390,14 @@ private function fill_table_recursive(&$element) {
} else {
$class .= ($type == 'categoryitem' or $type == 'courseitem') ? " ".$alter."d$depth baggb" : " item b1b";
}
+ if ($type == 'categoryitem' or $type == 'courseitem') { $header_cat = "cat_{$grade_object->iteminstance}_{$this->user->id}"; }
/// Name
$data['itemname']['content'] = $fullname;
$data['itemname']['class'] = $class;
$data['itemname']['colspan'] = ($this->maxdepth - $depth);
+ $data['itemname']['celltype'] = 'th';
+ $data['itemname']['id'] = $header_row;
/// Actual Grade
$gradeval = $grade_grade->finalgrade;
@@ -404,6 +410,7 @@ private function fill_table_recursive(&$element) {
if ($this->showweight) {
$data['weight']['class'] = $class;
$data['weight']['content'] = '-';
+ $data['weight']['headers'] = "$header_cat $header_row weight";
// has a weight assigned, might be extra credit
if ($grade_object->aggregationcoef > 0 && $type <> 'courseitem') {
$data['weight']['content'] = number_format($grade_object->aggregationcoef,2).'%';
@@ -429,12 +436,14 @@ private function fill_table_recursive(&$element) {
$gradeval = $this->blank_hidden_total($this->courseid, $grade_grade->grade_item, $gradeval);
$data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);
}
+ $data['grade']['headers'] = "$header_cat $header_row grade";
}
// Range
if ($this->showrange) {
$data['range']['class'] = $class;
$data['range']['content'] = $grade_grade->grade_item->get_formatted_range(GRADE_DISPLAY_TYPE_REAL, $this->rangedecimals);
+ $data['range']['headers'] = "$header_cat $header_row range";
}
// Percentage
@@ -449,6 +458,7 @@ private function fill_table_recursive(&$element) {
$data['percentage']['class'] = $class;
$data['percentage']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE);
}
+ $data['percentage']['headers'] = "$header_cat $header_row percentage";
}
// Lettergrade
@@ -467,6 +477,7 @@ private function fill_table_recursive(&$element) {
$data['lettergrade']['class'] = $class;
$data['lettergrade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true, GRADE_DISPLAY_TYPE_LETTER);
}
+ $data['lettergrade']['headers'] = "$header_cat $header_row lettergrade";
}
// Rank
@@ -494,6 +505,7 @@ private function fill_table_recursive(&$element) {
$data['rank']['class'] = $class;
$data['rank']['content'] = "$rank/".$this->get_numusers(false); // total course users
}
+ $data['rank']['headers'] = "$header_cat $header_row rank";
}
// Average
@@ -504,6 +516,7 @@ private function fill_table_recursive(&$element) {
} else {
$data['average']['content'] = '-';
}
+ $data['average']['headers'] = "$header_cat $header_row average";
}
// Feedback
@@ -518,6 +531,7 @@ private function fill_table_recursive(&$element) {
$data['feedback']['class'] = $classfeedback.' feedbacktext';
$data['feedback']['content'] = format_text($grade_grade->feedback, $grade_grade->feedbackformat);
}
+ $data['feedback']['headers'] = "$header_cat $header_row feedback";
}
}
}
@@ -534,6 +548,8 @@ private function fill_table_recursive(&$element) {
}
$data['itemname']['colspan'] = ($this->maxdepth - $depth + count($this->tablecolumns) - 1);
$data['itemname']['content'] = $fullname;
+ $data['itemname']['celltype'] = 'th';
+ $data['itemname']['id'] = "cat_{$grade_object->id}_{$this->user->id}";
}
/// Add this row to the overall system
@@ -557,13 +573,13 @@ public function print_table($return=false) {
/// Build table structure
$html = "
- <table cellspacing='0' cellpadding='0' class='boxaligncenter generaltable user-grade'>
+ <table cellspacing='0' cellpadding='0' summary='{$this->get_lang_string('tablesummary', 'gradereport_user')}' class='boxaligncenter generaltable user-grade'>
<thead>
<tr>
- <th class=\"header\" colspan='$maxspan'>".$this->tableheaders[0]."</th>\n";
+ <th id='".$this->tablecolumns[0]."' class=\"header\" colspan='$maxspan'>".$this->tableheaders[0]."</th>\n";
for ($i = 1; $i < count($this->tableheaders); $i++) {
- $html .= "<th class=\"header\">".$this->tableheaders[$i]."</th>\n";
+ $html .= "<th id='".$this->tablecolumns[$i]."' class=\"header\">".$this->tableheaders[$i]."</th>\n";
}
$html .= "
@@ -584,8 +600,11 @@ public function print_table($return=false) {
$class = (isset($this->tabledata[$i][$name]['class'])) ? $this->tabledata[$i][$name]['class'] : '';
$colspan = (isset($this->tabledata[$i][$name]['colspan'])) ? "colspan='".$this->tabledata[$i][$name]['colspan']."'" : '';
$content = (isset($this->tabledata[$i][$name]['content'])) ? $this->tabledata[$i][$name]['content'] : null;
+ $celltype = (isset($this->tabledata[$i][$name]['celltype'])) ? $this->tabledata[$i][$name]['celltype'] : 'td';
+ $id = (isset($this->tabledata[$i][$name]['id'])) ? "id='{$this->tabledata[$i][$name]['id']}'" : '';
+ $headers = (isset($this->tabledata[$i][$name]['headers'])) ? "headers='{$this->tabledata[$i][$name]['headers']}'" : '';
if (isset($content)) {
- $html .= "<td class='$class' $colspan>$content</td>\n";
+ $html .= "<$celltype $id $headers class='$class' $colspan>$content</$celltype>\n";
}
}
$html .= "</tr>\n";
View
51 grade/report/user/styles.css
@@ -11,26 +11,47 @@
.user-grade td {margin: 1px;padding: 0.25em;min-width: 2em;vertical-align: top;}
.user-grade thead {border-bottom: 3px double black;}
.user-grade thead th {padding: 0.25em 0.75em;}
-.user-grade td.oddd1 {background-color: #f3dfd0;}
-.user-grade td.oddd2 {background-color: #d0dbf3;}
-.user-grade td.oddd3 {background-color: #d0f3d6;}
-.user-grade td.oddd4 {background-color: #f0f0aa;}
-.user-grade td.evend2 {background-color: #b0bbd3;}
-.user-grade td.evend3 {background-color: #b0dfb6;}
-.user-grade td.evend4 {background-color: #cac8be;}
+.user-grade tbody th {text-align:left;}
+.user-grade td.oddd1,
+.user-grade th.oddd1 {background-color: #f3dfd0;}
+.user-grade td.oddd2,
+.user-grade th.oddd2 {background-color: #d0dbf3;}
+.user-grade td.oddd3,
+.user-grade th.oddd3 {background-color: #d0f3d6;}
+.user-grade td.oddd4,
+.user-grade th.oddd4 {background-color: #f0f0aa;}
+.user-grade td.evend2,
+.user-grade th.evend2 {background-color: #b0bbd3;}
+.user-grade td.evend3,
+.user-grade th.evend3 {background-color: #b0dfb6;}
+.user-grade td.evend4,
+.user-grade th.evend4 {background-color: #cac8be;}
.user-grade td.b1t,
-.user-grade td.b2t {border-top: 2px solid black;}
+.user-grade td.b2t,
+.user-grade th.b1t,
+.user-grade th.b2t {border-top: 2px solid black;}
.user-grade td.b1r,
-.user-grade td.b2r {border-right: 2px solid black;}
+.user-grade td.b2r,
+.user-grade th.b1r,
+.user-grade th.b2r {border-right: 2px solid black;}
.user-grade td.b1b,
-.user-grade td.b2b {border-bottom: 2px solid black;}
+.user-grade td.b2b,
+.user-grade th.b1b,
+.user-grade th.b2b {border-bottom: 2px solid black;}
.user-grade td.b1l,
-.user-grade td.b2l {border-left: 2px solid black;}
+.user-grade td.b2l,
+.user-grade th.b1l,
+.user-grade th.b2l {border-left: 2px solid black;}
.user-grade td.baggt,
-.user-grade td.baggb {font-style: italic;font-weight: bold;}
-.user-grade td.baggt {border-top: 3px double black;}
-.user-grade td.baggb {border-bottom: 3px double black;}
-.user-grade td.item {border-left: 1px solid gray;border-right: 1px solid gray;}
+.user-grade td.baggb,
+.user-grade th.baggt,
+.user-grade th.baggb {font-style: italic;font-weight: bold;}
+.user-grade td.baggt,
+.user-grade th.baggt {border-top: 3px double black;}
+.user-grade td.baggb,
+.user-grade th.baggb {border-bottom: 3px double black;}
+.user-grade td.item,
+.user-grade th.item {border-left: 1px solid gray;border-right: 1px solid gray}
.user-grade td.excluded {background-color: #666;}
.user-grade td.hidden {color: #aaa;}
.user-grade td.feedbacktext {max-width:600px;padding:2px 2px;}

0 comments on commit 95ad1ce

Please sign in to comment.