Index: functions.js
===================================================================
--- functions.js	(revision 8680)
+++ functions.js	(working copy)
@@ -14,15 +14,42 @@
 }
 
 /** highlight/unset the column of a table **/
-function set_col(idx) {
+function set_col(idx, increase) {
+	if(increase){
+		idx++;
+	}
+	
     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', '');
+		/** Check for the index existing, and verify it is not a filler row, which don't need the be vmarked **/
+        if (table.rows[i].cells[idx] && table.rows[i].cells[idx].className.search(/filler/) == -1) {
+			/** If we are on an item row that means we are at the header portion that is spaced over by the colspan
+			    that needs its index reduced by one to be vmarked with the index passfor the column **/
+			if(table.rows[i].cells[idx].className.search(/item/) != -1){			
+				if (table.rows[i].cells[idx-increase].className.search(/vmarked/) != -1) {
+	                table.rows[i].cells[idx-increase].className = table.rows[i].cells[idx-increase].className.replace(' vmarked', '');
+	            } else {
+	                table.rows[i].cells[idx-increase].className += ' vmarked';
+	            }
+			} else {
+            	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';
+            	}
+			}
+		/** Skip and row that is a filler **/
+        } else if (table.rows[i].cells[idx] && table.rows[i].cells[idx].className.search(/filler/) != -1){
+			continue;
+		/** We are at the last row, which means the index for the cell being increated has failed the does the 
+		   cell exist check.  Check if the next row down has a cell at the index.  If so we know we are at the  
+		   last row and still need to highlight the header**/
+		} else if(table.rows[i+increase].cells[idx] && table.rows[i].cells[idx-increase]){
+			if (table.rows[i].cells[idx-increase].className.search(/vmarked/) != -1) {
+                table.rows[i].cells[idx-increase].className = table.rows[i].cells[idx-increase].className.replace(' vmarked', '');
             } else {
-                table.rows[i].cells[idx].className += ' vmarked';
+                table.rows[i].cells[idx-increase].className += ' vmarked';
             }
-        }
+		}
     }
 }
\ No newline at end of file
Index: lib.php
===================================================================
--- lib.php	(revision 8680)
+++ lib.php	(working copy)
@@ -657,7 +657,16 @@
                     }
 
                     $headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
-                    $headerhtml .= '<th class=" '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex)">'
+
+					 //need to distinguish between 2 different styling for 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;
+					}
+                    $headerhtml .= '<th class=" '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex,'.$incrementcellindex. ')">'
                                 . shorten_text($headerlink) . $arrow;
                     $headerhtml .= '</th>';
                 }
@@ -1166,9 +1175,9 @@
 
             $fixedstudents = $this->is_fixed_students();
             if (!$fixedstudents) {
-                $colspan='';
+                $colspan='colspan="2" ';
                 if ($this->get_pref('showuseridnumber')) {
-                    $colspan = 'colspan="2" ';
+                    $colspan = 'colspan="3" ';
                 }
                 $avghtml .= '<th class="header c0 range" '.$colspan.' scope="row">'.$straverage.'</th>';
             }
