Example #1
0
function compare_gen($select_name, $xset_name, $n, $a1, $d1, $x, $a2, $d2)
{
    global $course;
    $top_unit = (require_once $course->doc_file());
    $select_unit = lookup_unit($top_unit, $select_name);
    if (!$select_unit) {
        error_page("no such select unit");
    }
    if (!lookup_unit($top_unit, $xset_name)) {
        error_page("no such xset");
    }
    $m = count($select_unit->units);
    for ($i = 0; $i < $n; $i++) {
        $uid = random_student();
        $t1 = time();
        $t2 = $t1 + 1;
        $j = rand(0, $m - 1);
        $child = $select_unit->units[$j];
        BoltSelectFinished::insert("(user_id, course_id, end_time, name, selected_unit) values ({$uid}, {$course->id}, {$t1}, '{$select_name}', '{$child->name}')");
        if ($child->name == $x) {
            $score = urand($a2, $d2);
        } else {
            $score = urand($a1, $d1);
        }
        BoltXsetResult::insert("(create_time, user_id, course_id, start_time, end_time, name, score) values ({$t2}, {$uid}, {$course->id}, {$t2}, {$t2}, '{$xset_name}', {$score})");
    }
}
Example #2
0
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 "\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"" . URL_BASE . "bolt_admin.css\">\n\t\tThe following compares the alternatives of\n\t\t<b>{$select_name}</b> with respect to <b>{$xset_name}</b>.\n\t\t<p>\n\t";
    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 "\n\t\t<form action=bolt_compare.php>\n\t\t<input type=hidden name=action value=compare>\n\t\t<input type=hidden name=course_id value={$course_id}>\n\t\t<input type=hidden name=select_name value=\"{$select_name}\">\n\t\t<input type=hidden name=xset_name value=\"{$xset_name}\">\n\t\t<table width=600><tr><td>\n\t";
    filter_form($filter ? $filter->name() : "", $filter_cat);
    echo "</td><td>";
    breakdown_form($breakdown ? $breakdown->name() : "");
    echo "\n\t\t</td></tr></table>\n\t\t<p>\n\t\t<input type=submit value=OK>\n\t\t</form>\n\t";
    admin_page_tail();
}