gradebook MDL-23750 category and item page had extra cells due to partial refactoring
authorAndrew Davis <andrew@affinitysoftware.net>
Wed, 11 Aug 2010 06:54:40 +0000 (06:54 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Wed, 11 Aug 2010 06:54:40 +0000 (06:54 +0000)
grade/edit/tree/lib.php
lib/outputcomponents.php

index fb3bec6..cd4b953 100755 (executable)
@@ -1164,7 +1164,8 @@ class grade_edit_tree_column_select extends grade_edit_tree_column {
         if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
             $itemselect = '<input class="itemselect" type="checkbox" name="select_'.$params['eid'].'" onchange="toggleCategorySelector();"/>'; // TODO: convert to YUI handler
         }
-        return '<td class="cell last selection">' . $itemselect . '</td>';
+        //html_writer::table() will wrap the item cell contents in a <TD> so don't do it here
+        return $itemselect;
     }
 
     public function is_hidden($mode='simple') {
index ac8f14e..366cdb9 100644 (file)
@@ -1194,6 +1194,7 @@ class html_writer {
 
         if (!empty($table->head)) {
             $countcols = count($table->head);
+
             $output .= html_writer::start_tag('thead', array()) . "\n";
             $output .= html_writer::start_tag('tr', array()) . "\n";
             $keys = array_keys($table->head);
@@ -1289,7 +1290,13 @@ class html_writer {
                     $keys2 = array_keys($row->cells);
                     $lastkey = end($keys2);
 
+                    $gotlastkey = false; //flag for sanity checking
                     foreach ($row->cells as $key => $cell) {
+                        if ($gotlastkey) {
+                            //This should never happen. Why do we have a cell after the last cell?
+                            mtrace("A cell with key ($key) was found after the last key ($lastkey)");
+                        }
+
                         if (!($cell instanceof html_table_cell)) {
                             $mycell = new html_table_cell();
                             $mycell->text = $cell;
@@ -1307,6 +1314,7 @@ class html_writer {
                         $cell->attributes['class'] .= ' cell c' . $key;
                         if ($key == $lastkey) {
                             $cell->attributes['class'] .= ' lastcol';
+                            $gotlastkey = true;
                         }
                         $tdstyle = '';
                         $tdstyle .= isset($table->align[$key]) ? $table->align[$key] : '';