bolt->update("sex=$sex, birth_year=$birth_year"); } $course_doc = require_once($course->doc_file); function finalize_view($user, $view_id, $action) { if (!$view_id) return null; $view = BoltView::lookup_id($view_id); if ($view && $view->user_id == $user->id && !$view->end_time) { $now = time(); $view->update("end_time=$now, action=$action"); return $view; } return null; } function default_mode($item) { return $item->is_exercise()?BOLT_MODE_SHOW:BOLT_MODE_LESSON; } function create_view($user, $course, $item, $mode) { $now = time(); return BoltView::insert("(user_id, course_id, item_name, start_time, mode) values ($user->id, $course->id, '$item->name', $now, $mode)"); } function get_current_item($e, $course_doc) { $frac_done = 0; $iter = new BoltIter($course_doc); $iter->decode_state($e->state); $iter->at(); return $iter; } function get_next_item($e, $course_doc) { $iter = new BoltIter($course_doc); $iter->decode_state($e->state); $iter->next(); $state = $iter->encode_state(); $e->update("state='$state'"); return $iter; } function show_item( $item, $frac_done, $user, $course, $e, $view_id, $mode ) { global $bolt_ex_mode; global $bolt_ex_index; $now = time(); $e->update("last_view=$now, fraction_done=$frac_done"); if ($item->is_exercise()) { $bolt_ex_mode = $mode; $bolt_ex_index = 0; switch ($mode) { case BOLT_MODE_SHOW: echo "