diff --git a/bolt_checkin_notes.txt b/bolt_checkin_notes.txt index 0159e87892..8a6d40fc2e 100644 --- a/bolt_checkin_notes.txt +++ b/bolt_checkin_notes.txt @@ -99,3 +99,13 @@ David Feb 1 2008 user/ bolt.php bolt_sched.php + +David Feb 6 2008 + - implemented question mechanism + + html/ + inc/ + bolt.inc + user/ + bolt_course.php + bolt_sched.php diff --git a/html/inc/bolt.inc b/html/inc/bolt.inc index 5fd3b526ad..dfb6939f75 100644 --- a/html/inc/bolt.inc +++ b/html/inc/bolt.inc @@ -199,7 +199,7 @@ function lesson() { } } if (!$name) { - error_page("Missing name in lesson"); + $name = $file; } if (!$title) { $title = $name; @@ -226,10 +226,7 @@ function exercise() { } } if (!$name) { - error_page("Missing name in lesson"); - } - if (!$title) { - $title = $name; + $name = $file; } if (!$file) { error_page("Missing filename in lesson"); diff --git a/html/user/bolt_course.php b/html/user/bolt_course.php index f73fcfcee7..af2aa36a73 100644 --- a/html/user/bolt_course.php +++ b/html/user/bolt_course.php @@ -54,7 +54,9 @@ function show_view($view) { $dur $view->item_name ".mode_name($view->mode)." $x - ".phase_name($view->phase)." + "; + //".phase_name($view->phase)." + echo " ".action_name($view->action)." "; @@ -67,7 +69,9 @@ function show_views() { $views = BoltView::enum("user_id=$user->id and course_id=$course->id order by id desc"); start_table(); - table_header("Time", "Duration", "Item", "Mode", "Phase", "Action"); + table_header("Time", "Duration", "Item", "Mode", + // "Phase", + "Action"); foreach ($views as $view) { show_view($view); } diff --git a/html/user/bolt_sched.php b/html/user/bolt_sched.php index 53b6773209..d3d7778aae 100644 --- a/html/user/bolt_sched.php +++ b/html/user/bolt_sched.php @@ -62,28 +62,42 @@ function create_view($iter, $mode, $prev_view_id) { return BoltView::insert("(user_id, course_id, item_name, start_time, mode, state, fraction_done, prev_view_id) values ($user->id, $course->id, '$item->name', $now, $mode, '$state', $iter->frac_done, $prev_view_id)"); } +function page_header($title) { + echo "$title + + + "; + if (function_exists('bolt_header')) bolt_header($title); +} + +function page_footer() { + if (function_exists('bolt_footer')) bolt_footer(); + echo ""; +} + // show a page saying the course has been completed // function show_finished_page($view_id, $prev_view_id) { global $course; global $url_args; - if (function_exists('bolt_header')) bolt_header("Course completed"); + page_header("Course completed"); echo "Congratulations - you have completed this course."; $links[] = ""; $up_link = "Course home page"; - show_nav($links, $up_link); - if (function_exists('bolt_footer')) bolt_footer(); + show_nav($links, $up_link, $view_id); + page_footer(); } function show_refresh_finished() { - if (function_exists('bolt_header')) bolt_header("Refresh completed"); + page_header("Refresh completed"); echo "Refresh finished"; - if (function_exists('bolt_footer')) bolt_footer(); + page_footer(); } -function show_nav($links, $up_link) { +function show_nav($links, $up_link, $view_id) { global $course; + echo "

"; @@ -93,9 +107,14 @@ function show_nav($links, $up_link) { echo "


- +
+ id> + + +
+

$up_link "; @@ -114,7 +133,7 @@ function show_item($iter, $view_id, $prev_view_id, $mode, $repeat=null) { global $url_args; $item = $iter->item; - if (function_exists('bolt_header')) bolt_header($item->title); + page_header($item->title); $bolt_query_string = $item->query_string; $links = array(); @@ -158,16 +177,17 @@ function show_item($iter, $view_id, $prev_view_id, $mode, $repeat=null) { } if ($repeat) { + echo "

Your average score on this group of exercises: $repeat->avg_score"; if ($repeat->flags & REVIEW) { - echo "

";
-            print_r($repeat);
-            echo "
"; + //echo "
";
+            //print_r($repeat);
+            //echo "
"; $name = urlencode($repeat->unit->name); - $r = "Review"; + $r = "Review, then repeat exercises"; $links[] = $r; } if ($repeat->flags & REPEAT) { - $r = "Repeat"; + $r = "Repeat exercises"; $links[] = $r; } if ($repeat->flags & NEXT) { @@ -178,9 +198,9 @@ function show_item($iter, $view_id, $prev_view_id, $mode, $repeat=null) { } $up_link = "Course home page"; - show_nav($links, $up_link); + show_nav($links, $up_link, $view_id); - if (function_exists('bolt_footer')) bolt_footer(); + page_footer(); if ($refresh) { $refresh->update("last_view_id=$view_id"); @@ -203,14 +223,13 @@ function show_answer_page($iter, $score) { $bolt_ex_index = 0; $item = $iter->item; - page_head(null); - if (function_exists('bolt_header')) bolt_header($item->title); + page_header($item->title); $bolt_query_string = $item->query_string; require_once($item->filename); if (function_exists('bolt_divide')) bolt_divide(); $score_pct = number_format($score*100); echo "Score: $score_pct%"; - if (function_exists('bolt_footer')) bolt_footer(); + page_footer(); } function start_course() { @@ -397,8 +416,10 @@ case 'answer': // submit answer in exercise // If this is part of an exercise set, call its callback function // + $repeat = null; if ($iter->xset) { $is_last = $iter->xset->xset_callback($iter, $bolt_ex_score, $view->id, $avg_score, $repeat); + if ($repeat) $repeat->avg_score = $avg_score; if ($is_last) { // if the exercise set if finished, make or update DB records // @@ -423,7 +444,6 @@ case 'answer': // submit answer in exercise srand($view_id); $view_id = create_view($iter, BOLT_MODE_ANSWER, $view->id); - $repeat = null; show_item($iter, $view_id, $view->id, BOLT_MODE_ANSWER, $repeat); break; case 'answer_page': @@ -481,7 +501,7 @@ case 'refresh': $refresh_id = get_int('refresh_id'); $refresh = BoltRefreshRec::lookup_id($refresh_id); if (!$refresh) error_page("refresh not found"); - + // fall through case 'resume': if ($refresh) { if ($refresh->last_view_id) { @@ -516,7 +536,6 @@ case 'resume': $view_orig = BoltView::lookup_id($view->prev_view_id); $result = BoltResult::lookup_id($view_orig->result_id); srand($view_orig->id); - echo "reshow: $result->response"; $bolt_ex_query_string = $result->response; $bolt_ex_score = $result->score; $bolt_ex_index = 0; @@ -527,6 +546,22 @@ case 'resume': show_item($iter, $view_id, $view->id, $mode); } break; +case 'question': + $view = finalize_view($view_id, BOLT_ACTION_QUESTION); + $now = time(); + $question = BoltDb::escape_string(get_str('question')); + BoltQuestion::insert("(create_time, user_id, course_id, name, question, state) values ($now, $user->id, $course->id, '$view->item_name', '$question', 0)"); + page_header("Question recorded"); + echo " + Thanks; we have recorded your question. + Questions help us improve this course. + We aren't able to individually respond to all questions. + Responses are delivered as private messages. +

+ Resume course + "; + page_footer(); + break; default: error_page("unknown action: $action"); }