recs as $uid=>$x) {
if ($filter && $filter->categorize($x->user) != $filter_cat) {
//echo "
$uid rejected by filter ";
continue;
}
if ($breakdown && $breakdown->categorize($x->user) != $breakdown_cat) {
//echo "
$uid rejected by breakdown ";
continue;
}
$z = $x->sf->selected_unit;
$u = $x->sf->selected_unit;
$a[$u][] = $x->xr->score;
}
if ($title) {
echo "
$title |
";
}
foreach ($select_unit->units as $child) {
if (array_key_exists($child->name, $a)) {
$scores = $a[$child->name];
$n = count($scores);
if ($n < 2) {
$x = compare_bar_insuff($child->name, 600);
} else {
conf_int_90($scores, $lo, $hi);
//$x = "($lo, $hi) ($n results)";
$x = compare_bar($child->name, $n, 600, $lo, $hi);
}
} else {
$x = compare_bar_insuff($child->name, 600);
}
echo $x;
}
}
function compare_aux($select_name, $xset_name, $snap) {
global $top_unit;
global $course_id;
$breakdown_name = get_str('breakdown', true);
if ($breakdown_name) {
$breakdown = lookup_categorization($breakdown_name);
if (!$breakdown) error_page("unknown breakdown $breakdown_name");
} else {
$breakdown = null;
}
$filter_info = get_str('filter', true);
if ($filter_info && $filter_info != "none") {
$arr = explode(":", $filter_info);
$filter_name = $arr[0];
$filter_cat = $arr[1];
$filter = lookup_categorization($filter_name);
if (!$filter) error_page("unknown filter $filter_name");
} else {
$filter_name = "";
$filter_cat = "";
$filter = null;
}
$select_unit = lookup_unit($top_unit, $select_name);
if (!$select_unit) error_page("no select unit");
page_head("Unit comparison");
echo "
The following compares the alternatives of
$select_name with respect to $xset_name.
";
echo "
";
if ($breakdown) echo "Total |
";
compare_case(null, $select_unit, $snap, $filter, $filter_cat, null, null);
if ($breakdown) {
echo "Breakdown by $breakdown_name |
";
foreach ($breakdown->categories() as $c) {
compare_case($c, $select_unit, $snap, $filter, $filter_cat, $breakdown, $c);
echo "";
}
}
echo "
";
echo "
";
page_tail();
}
function show_compare() {
global $course_id;
$select_name = get_str('select_name');
$xset_name = get_str('xset_name');
$s = read_compare_snapshot($course_id, $select_name, $xset_name);
compare_aux($select_name, $xset_name, $s);
}
function show_snap_form($top_unit) {
global $course_id;
$select_name = get_str('select_name');
$xset_name = get_str('xset_name');
page_head("Data snapshot");
$s = read_compare_snapshot($course_id, $select_name, $xset_name);
if ($s) {
$end = date_str($s->time);
echo "
A data snapshot exists for the $s->dur days prior to $end.
";
show_button(
"bolt_compare.php?action=compare&course_id=$course_id&select_name=$select_name&xset_name=$xset_name",
"Use this snapshot",
"Use this snapshot"
);
} else {
echo "There is currently no snapshot.";
}
echo "
";
page_tail();
}
function snap_action() {
global $course_id;
$select_name = get_str('select_name');
$xset_name = get_str('xset_name');
$dur = get_int('dur');
$s = write_compare_snapshot($course_id, $select_name, $xset_name, $dur);
compare_aux($select_name, $xset_name, $s);
}
function show_choice($top_unit) {
global $course_id;
page_head("Unit comparison");
echo "