rendered paste body|1042 /**
| 1043 * This is not a real unit test, but an experimental attempt at building a HTML table
| 1044 * based on the sortorders set for each test grade_item.
| 1045 */
|- 1046 function test_grade_build_table() {
|| 1047 // Build an associative array of grade_items
|| 1048 $tree = array();
|| 1049
|| 1050 // 1. Fetch all top-level categories for this course, with all children preloaded, sorted by sortorder
|| 1051 $topcats = grade_category::get_tree($this->courseid);
|| 1052 $topcathtml = '<tr>';
|| 1053
|| 1054 foreach ($topcats as $topcat) {
|| 1055 $cathtml = '<tr>';
|| 1056 $itemcount = 0;
|| 1057 $itemhtml = '<tr>';
|| 1058
|| 1059 foreach ($topcat['children'] as $catkey => $cat) {
|| 1060 $catitemcount = 0;
|| 1061
|| 1062 foreach ($cat['children'] as $item) {
|| 1063 $itemcount++;
|| 1064 $catitemcount++;
|| 1065 $itemhtml .= '<td>' . $item['object']->itemname . '</td>';
|| 1066 }
|| 1067
|| 1068 $cat['object']->load_grade_item();
|| 1069 $cathtml .= '<td colspan="' . $catitemcount . '">' . $cat['object']->fullname . '</td>';
|| 1070 }
|| 1071 $topcathtml .= '<th colspan="' . $itemcount . '">' . $topcat['object']->fullname . '</th>';
|| 1072 }
|| 1073
|| 1074 $topcathtml .= '</tr>';
|| 1075 $cathtml .= '</tr>';
|| 1076 $itemhtml .= '</tr>';
|| 1077
|| 1078 echo "<table style=\"text-align: center\" border=\"1\">$topcathtml$cathtml$itemhtml</table>";
|| 1079
|| 1080 }