Esempio n. 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})");
    }
}
Esempio n. 2
0
function clear()
{
    global $course_id;
    admin_page_head("Deleting course data");
    BoltEnrollment::delete_aux("course_id = {$course_id}");
    BoltView::delete_aux("course_id = {$course_id}");
    BoltResult::delete_aux("course_id = {$course_id}");
    BoltXsetResult::delete_aux("course_id = {$course_id}");
    BoltSelectFinished::delete_aux("course_id = {$course_id}");
    BoltRefreshRec::delete_aux("course_id = {$course_id}");
    BoltQuestion::delete_aux("course_id = {$course_id}");
    echo "\n\t\tCourse data deleted.\n\t";
    admin_page_tail();
}