1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// actions:
// (none)
// form to choose select and xset; OK goes to:
// snap_form
// if have a snapshot, show its start/end times
// show form to get new snapshot
// snap_action
// make new snapshot
// compare(filter, breakdown)
// show comparison.
// show form to set or change filter or breakdown.
require_once("../inc/bolt_util_ops.inc");
require_once("../inc/bolt_db.inc");
require_once("../inc/bolt.inc");
require_once("../inc/bolt_cat.inc");
require_once("../inc/bolt_snap.inc");
require_once("../inc/util_ops.inc");
$filter = null;
$filter_cat = null;
$breakdown = null;
$breakdown_cat = null;
function compare_case(
$title, $select_unit, $snap, $filter, $filter_cat, $breakdown, $breakdown_cat
) {
// for each select alternative, build an array of xset scores
//
$a = array();
foreach ($snap->recs as $uid=>$x) {
if ($filter && $filter->categorize($x->user) != $filter_cat) {
//echo "<br>$uid rejected by filter ";
continue;
}
if ($breakdown && $breakdown->categorize($x->user) != $breakdown_cat) {
//echo "<br>$uid rejected by breakdown ";
continue;
}
$z = $x->sf->selected_unit;
$u = $x->sf->selected_unit;
$a[$u][] = $x->xr->score;
}
if ($title) {
echo "
<tr class=bolt_head2><td colspan=2><b>$title</b></td></tr>
";
}
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, $course_id, $filter, $filter_cat;
global $breakdown, $breakdown_cat;
get_filters_from_form();
$select_unit = lookup_unit($top_unit, $select_name);
if (!$select_unit) error_page("no select unit");
admin_page_head("Unit comparison");
echo "
<link rel=\"stylesheet\" type=\"text/css\" href=\"".URL_BASE."bolt_admin.css\">
The following compares the alternatives of
<b>$select_name</b> with respect to <b>$xset_name</b>.
<p>
";
echo "<table class=\"bolt_box\">";
if ($breakdown) echo "<tr class=bolt_head1><td colspan=2>Total</td></tr>";
compare_case(null, $select_unit, $snap, $filter, $filter_cat, null, null);
if ($breakdown) {
echo "<tr class=bolt_head1><td colspan=2>Breakdown by ".$breakdown->name()."</td></tr>";
foreach ($breakdown->categories() as $c) {
compare_case($c, $select_unit, $snap, $filter, $filter_cat, $breakdown, $c);
echo "<p>";
}
}
echo "</table>";
echo "
<form action=bolt_compare.php>
<input type=hidden name=action value=compare>
<input type=hidden name=course_id value=$course_id>
<input type=hidden name=select_name value=\"$select_name\">
<input type=hidden name=xset_name value=\"$xset_name\">
<table width=600><tr><td>
";
filter_form($filter?$filter->name():"", $filter_cat);
echo "</td><td>";
breakdown_form($breakdown?$breakdown->name():"");
echo "
</td></tr></table>
<p>
<input class=\"btn btn-default\" type=submit value=OK>
</form>
";
admin_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');
admin_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 "
<form action=bolt_compare.php>
<input type=hidden name=action value=snap_action>
<input type=hidden name=course_id value=$course_id>
<input type=hidden name=select_name value=\"$select_name\">
<input type=hidden name=xset_name value=\"$xset_name\">
Create a new snapshot using data from the last
<input name=dur value=7> days.
<input class=\"btn btn-default\" type=submit value=OK>
</form>
";
admin_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;
admin_page_head("Unit comparison");
echo "
<form action=bolt_compare.php>
<input type=hidden name=course_id value=$course_id>
This tool lets you compare alternative lessons.
These lessons must be included in a 'select' unit,
typically with a random selection function.
This must be followed by an exercise set
that tests for the concepts in the lessons.
<p>
Please choose a select unit
";
choose_select($top_unit);
echo "
and an exercise set
";
choose_xset($top_unit);
echo "
<input type=hidden name=action value=snap_form>
<p>
<input class=\"btn btn-default\" type=submit value=OK>
";
admin_page_tail();
}
$course_id = get_int('course_id');
$course = BoltCourse::lookup_id($course_id);
$top_unit = require_once($course->doc_file());
$action = get_str('action', true);
switch ($action) {
case "": show_choice($top_unit); break;
case "snap_form": show_snap_form($top_unit); break;
case "snap_action": snap_action(); break;
case "compare": show_compare(); break;
default: error_page("Unknown action $action");
}
?>
|