function start_refresh() { global $course_doc; global $refresh; $xset_result = BoltXsetResult::lookup_id($refresh->xset_result_id); if (!$xset_result) { error_page("Exercise set result not found"); } $view = BoltView::lookup_id($xset_result->view_id); if (!$view) { error_page("view not found"); } $iter = new BoltIter($course_doc); $iter->decode_state($view->state); $iter->at(); $xset = $iter->xset; if (!$xset || $xset->name != $xset_result->name) { error_page("missing exercise set"); } $xset->restart($iter); $iter->at(); $mode = default_mode($iter->item); $view_id = create_view($iter, $mode, 0); show_item($iter, $view_id, 0, $mode); }
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(); }
function map_gen_uid($uid, $unit, $sb) { global $course, $now; $class = get_class($unit); switch ($class) { case 'BoltExercise': return map_gen_ex($uid, $unit, $sb); case 'BoltLesson': return map_gen_lesson($uid, $unit, $sb); default: $ret = false; foreach ($unit->units as $u) { $ret = map_gen_uid($uid, $u, $sb); if (!$ret) { break; } } if ($ret && $class == 'BoltExerciseSet') { $score = urand($sb->score_mean, $sb->score_dev); BoltXsetResult::insert("(create_time, user_id, course_id, name, score) values ({$now}, {$uid}, {$course->id}, '{$unit->name}', {$score})"); } return $ret; } }