function notify_users() { $now = time(); $rs = BoltRefresh::enum("due_time < {$now}"); $users = array(); foreach ($rs as $r) { $view = BoltView::lookup_id($r->view_id); $user_id = $view->user_id; if (!key_exists($user_id)) { $user = BoincUser::lookup_id($user_id); BoltUser::lookup($user); $user->refresh = array(); $users[$user_id] = $user; } $users[$user_id]->refresh[] = $r; } foreach ($users as $user) { notify_user($user); } }
page_head("Courses"); $user = get_logged_in_user(false); if ($user) { BoltUser::lookup($user); } $courses = BoltCourse::enum(); start_table(); table_header("Course", "Status"); foreach ($courses as $course) { if ($course->hidden && !($user->bolt->flags & BOLT_FLAG_SHOW_ALL)) { continue; } $e = $user ? BoltEnrollment::lookup($user->id, $course->id) : null; if ($e) { $start = date_str($e->create_time); $view = BoltView::lookup_id($e->last_view_id); $ago = time_diff(time() - $view->start_time); $pct = number_format($view->fraction_done * 100, 0); $status = "Started {$start}\n <br>Last visit: {$ago} ago\n <br>{$pct}% done\n "; if ($view->fraction_done < 1) { $status .= "<br><a href=bolt_sched.php?course_id={$course->id}&action=resume>Resume</a>\n "; } $status .= "<br><a href=bolt_sched.php?course_id={$course->id}&action=start>Restart</a>\n | <a href=bolt_course.php?course_id={$course->id}>History</a>\n "; } else { $status = "\n <a href=bolt_sched.php?course_id={$course->id}&action=start>Start</a>\n "; } row2_init("<b>{$course->name}</b>\n <br><span class=note>{$course->description}</span>", $status); show_refreshes(); echo "</td></tr>\n"; } end_table();
function show_views() { global $user; global $course; $views = BoltView::enum("user_id={$user->id} and course_id={$course->id} order by id"); start_table(); table_header("ID", "Time", "Duration", "Item", "Mode", "Action"); foreach ($views as $view) { show_view($view); } end_table(); }
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 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 map_gen_lesson($uid, $unit, $sb) { global $course, $now; if (frand() < $sb->attr) { $action = BOLT_ACTION_NONE; $t = $now; } else { $action = BOLT_ACTION_NEXT; $t = $now + urand($sb->time_mean, $sb->time_dev); } $mode = BOLT_MODE_LESSON; BoltView::insert("(user_id, course_id, item_name, action, mode, start_time, end_time) values ({$uid}, {$course->id}, '{$unit->name}', {$action}, {$mode}, {$now}, {$t})"); return $action == BOLT_ACTION_NEXT; }