Skip to content
Browse files

gradebook MDL-21315 Fixed column highlighting

  • Loading branch information...
1 parent edab831 commit 1966cb853f9e19d419a7eaf28776d10053530f77 Andrew Davis committed
Showing with 29 additions and 10 deletions.
  1. +18 −8 grade/report/grader/functions.js
  2. +11 −2 grade/report/grader/lib.php
View
26 grade/report/grader/functions.js
@@ -14,15 +14,25 @@ function set_row(idx) {
}
/** highlight/unset the column of a table **/
-function set_col(idx) {
+function set_col(col,gradecelloffset) {
var table = document.getElementById('user-grades');
- for (var i = 1; i < table.rows.length; i++) {
- if (table.rows[i].cells[idx]) {
- if (table.rows[i].cells[idx].className.search(/vmarked/) != -1) {
- table.rows[i].cells[idx].className = table.rows[i].cells[idx].className.replace(' vmarked', '');
- } else {
- table.rows[i].cells[idx].className += ' vmarked';
- }
+
+ //highlight the column header
+ flip_vmarked(table,2,col);
+
+ //add any grade cell offset (due to colspans) then iterate down the table
+ col += gradecelloffset;
+ for (var row = 3; row < table.rows.length; row++) {
+ flip_vmarked(table,row,col);
+ }
+}
+
+function flip_vmarked(table,row,col) {
+ if (table.rows[row].cells[col]) {
+ if (table.rows[row].cells[col].className.search(/vmarked/) != -1) {
+ table.rows[row].cells[col].className = table.rows[row].cells[col].className.replace(' vmarked', '');
+ } else {
+ table.rows[row].cells[col].className += ' vmarked';
}
}
}
View
13 grade/report/grader/lib.php
@@ -657,9 +657,18 @@ function get_headerhtml() {
$hidden = ' hidden ';
}
- $headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
+ $headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
+
+ //The width of the table varies depending on fixedstudents.
+ // $fixedstudents == 0, students and grades display in the same table.
+ // $fixedstudents == 1, students and grades are display in separate table.
+ if ($fixedstudents) {
+ $incrementcellindex = '0';
+ } else {
+ $incrementcellindex = '1';
+ }
//MDL-21088 - IE 7 ignores nowraps on tds or ths so we this in a span with a nowrap on it.
- $headerhtml .= '<th class=" '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex)"><span>'
+ $headerhtml .= '<th class=" '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex,' . $incrementcellindex . ')"><span>'
.shorten_text($headerlink) . $arrow;
$headerhtml .= '</span></th>';
}

0 comments on commit 1966cb8

Please sign in to comment.
Something went wrong with that request. Please try again.