/** * This is not a real unit test, but an experimental attempt at building a HTML table * based on the sortorders set for each test grade_item. */ function test_grade_build_table() { // Build an associative array of grade_items $tree = array(); // 1. Fetch all top-level categories for this course, with all children preloaded, sorted by sortorder $topcats = grade_category::get_tree($this->courseid); $topcathtml = '<tr>'; foreach ($topcats as $topcat) { $cathtml = '<tr>'; $itemcount = 0; $itemhtml = '<tr>'; foreach ($topcat['children'] as $catkey => $cat) { $catitemcount = 0; foreach ($cat['children'] as $item) { $itemcount++; $catitemcount++; $itemhtml .= '<td>' . $item['object']->itemname . '</td>'; } $cat['object']->load_grade_item(); $cathtml .= '<td colspan="' . $catitemcount . '">' . $cat['object']->fullname . '</td>'; } $topcathtml .= '<th colspan="' . $itemcount . '">' . $topcat['object']->fullname . '</th>'; } $topcathtml .= '</tr>'; $cathtml .= '</tr>'; $itemhtml .= '</tr>'; echo "<table style=\"text-align: center\" border=\"1\">$topcathtml$cathtml$itemhtml</table>"; }