mirror of https://github.com/BOINC/boinc.git
David Dec 19 2007
- May as well start keeping checkin notes for Bolt. At this point the fundamental structure of Bolt is more or less complete, I hope; many features are missing. Items for this particular checkin: - Make things work right when you resume a course at an exercise answer page. This creates a new View, whose prev_view_id link points to the exercise view, not the answer page view - When leave a page using "Up", terminate the view accordingly. - Rather than using $_GET, Form vars are now passed to exercise primitives in a global variable $bolt_ex_query_string, which they must parse. svn path=/trunk/boinc/; revision=14414
This commit is contained in:
parent
a2269c9c13
commit
c3491a40d9
|
@ -0,0 +1,24 @@
|
|||
David Dec 19 2007
|
||||
- May as well start keeping checkin notes for Bolt.
|
||||
At this point the fundamental structure of Bolt is
|
||||
more or less complete, I hope; many features are missing.
|
||||
|
||||
Items for this particular checkin:
|
||||
|
||||
- Make things work right when you resume a course at an
|
||||
exercise answer page.
|
||||
This creates a new View, whose prev_view_id link points
|
||||
to the exercise view, not the answer page view
|
||||
- When leave a page using "Up", terminate the view accordingly.
|
||||
- Rather than using $_GET, Form vars are now passed to exercise primitives
|
||||
in a global variable $bolt_ex_query_string, which they must parse.
|
||||
|
||||
db/
|
||||
bolt_schema.sql
|
||||
html/
|
||||
inc/
|
||||
bolt_db.inc
|
||||
bolt_ex.inc
|
||||
user/
|
||||
bolt_course.php
|
||||
bolt_sched.php
|
|
@ -45,6 +45,8 @@ create table bolt_view (
|
|||
start_time integer not null,
|
||||
end_time integer not null,
|
||||
prev_view_id integer not null,
|
||||
-- for exercise answer views,
|
||||
-- this always refers to the original exercise show
|
||||
fraction_done double not null,
|
||||
result_id integer not null,
|
||||
-- if this was an exercise show, link to result record
|
||||
|
@ -58,8 +60,10 @@ create table bolt_view (
|
|||
create table bolt_exercise_result (
|
||||
id integer not null auto_increment,
|
||||
view_id integer not null,
|
||||
-- the original display of exercise
|
||||
score double not null,
|
||||
response text not null,
|
||||
-- the query string containing user's responses
|
||||
primary key(id)
|
||||
);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ define('BOLT_ACTION_NEXT', 1);
|
|||
define('BOLT_ACTION_PREV', 2);
|
||||
define('BOLT_ACTION_SUBMIT', 3);
|
||||
define('BOLT_ACTION_QUESTION', 4);
|
||||
define('BOLT_ACTION_COURSE_HOME', 5);
|
||||
|
||||
class BoltDb extends DbConn {
|
||||
static $instance;
|
||||
|
|
|
@ -4,11 +4,15 @@ $bolt_ex_mode = 0;
|
|||
$bolt_ex_index = 0;
|
||||
$bolt_ex_state = 0;
|
||||
$bolt_ex_score = 0;
|
||||
$bolt_ex_query_string = "";
|
||||
|
||||
function bolt_exclusive_choice($choices) {
|
||||
global $bolt_ex_mode; // input
|
||||
global $bolt_ex_index; // input
|
||||
global $bolt_ex_score; // incremental output if SCORE
|
||||
global $bolt_ex_query_string;
|
||||
|
||||
parse_str($bolt_ex_query_string);
|
||||
|
||||
switch ($bolt_ex_mode) {
|
||||
case BOLT_MODE_SHOW:
|
||||
|
@ -25,8 +29,8 @@ function bolt_exclusive_choice($choices) {
|
|||
$right_ans = $choices[0];
|
||||
shuffle($choices);
|
||||
$key = "q_$bolt_ex_index";
|
||||
if (array_key_exists($key, $_GET)) {
|
||||
$response = $_GET[$key];
|
||||
if (isset($$key)) {
|
||||
$response = $$key;
|
||||
if ($choices[$response] == $right_ans) {
|
||||
$bolt_ex_score += 1;
|
||||
}
|
||||
|
@ -36,8 +40,8 @@ function bolt_exclusive_choice($choices) {
|
|||
$right_ans = $choices[0];
|
||||
shuffle($choices);
|
||||
$key = "q_$bolt_ex_index";
|
||||
if (array_key_exists($key, $_GET)) {
|
||||
$response = $_GET[$key];
|
||||
if (isset($$key)) {
|
||||
$response = $$key;
|
||||
} else {
|
||||
$response = -1;
|
||||
}
|
||||
|
@ -60,6 +64,9 @@ function bolt_inclusive_choice($choices) {
|
|||
global $bolt_ex_mode; // input
|
||||
global $bolt_ex_index; // input
|
||||
global $bolt_ex_score; // incremental output if SCORE
|
||||
global $bolt_ex_query_string;
|
||||
|
||||
parse_str($bolt_ex_query_string);
|
||||
|
||||
switch ($bolt_ex_mode) {
|
||||
case BOLT_MODE_SHOW:
|
||||
|
@ -80,7 +87,7 @@ function bolt_inclusive_choice($choices) {
|
|||
shuffle($choices);
|
||||
foreach ($choices as $choice) {
|
||||
$key = "q_".$bolt_ex_index."_$i";
|
||||
$response = array_key_exists($key, $_GET);
|
||||
$response = isset($$key);
|
||||
$r = $choice[1];
|
||||
$correct = ($r && $response) || (!$r && !$response);
|
||||
if ($correct) $score += 1./$n;
|
||||
|
@ -97,7 +104,7 @@ function bolt_inclusive_choice($choices) {
|
|||
foreach ($choices as $choice) {
|
||||
$c = $choice[0];
|
||||
$key = "q_".$bolt_ex_index."_$i";
|
||||
$response = array_key_exists($key, $_GET);
|
||||
$response = isset($$key);
|
||||
$r = $choice[1];
|
||||
$correct = ($r && $response) || (!$r && !$response);
|
||||
table_row($c, $r?"yes":"no", $response?"yes":"no");
|
||||
|
@ -115,6 +122,8 @@ function bolt_image_rect($img, $rect) {
|
|||
global $bolt_ex_state; // output if SHOW, else input
|
||||
global $bolt_ex_score; // incremental output if SCORE
|
||||
|
||||
parse_str($bolt_ex_query_string);
|
||||
|
||||
switch ($bolt_ex_mode) {
|
||||
case BOLT_MODE_SHOW:
|
||||
echo "<img src=$img";
|
||||
|
|
|
@ -21,6 +21,7 @@ function action_name($action) {
|
|||
case BOLT_ACTION_PREV: return "Previous";
|
||||
case BOLT_ACTION_SUBMIT: return "Submit";
|
||||
case BOLT_ACTION_QUESTION: return "Question";
|
||||
case BOLT_ACTION_COURSE_HOME: return "Course home";
|
||||
default: return "unknown: $action";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ function show_item($iter, $user, $course, $view_id, $prev_view_id, $mode) {
|
|||
<center>
|
||||
<table width=60%><tr>
|
||||
<td width=33% align=left>$prev</td>
|
||||
<td width=33% align=center><a href=bolt.php>Up</a></td>
|
||||
<td width=33% align=center><a href=bolt_sched.php?course_id=$course->id&action=course_home&view_id=$view_id>Up</a></td>
|
||||
<td width=33% align=right>$next</td>
|
||||
</table>
|
||||
</center>
|
||||
|
@ -253,6 +253,7 @@ case 'answer': // submit answer in exercise
|
|||
if ($view->item_name != $item->name) {
|
||||
error_page("unexpected name");
|
||||
}
|
||||
$bolt_ex_query_string = $_SERVER['QUERY_STRING'];
|
||||
$bolt_ex_mode = BOLT_MODE_SCORE;
|
||||
$bolt_ex_index = 0;
|
||||
$bolt_ex_score = 0;
|
||||
|
@ -283,8 +284,13 @@ case 'answer_page':
|
|||
}
|
||||
$result = BoltResult::lookup_id($view->result_id);
|
||||
srand($view_id);
|
||||
$bolt_ex_query_string = $result->response;
|
||||
show_answer_page($iter, $result->score);
|
||||
break;
|
||||
case 'course_home':
|
||||
$view = finalize_view($user, $view_id, BOLT_ACTION_COURSE_HOME);
|
||||
Header("Location: bolt.php");
|
||||
break;
|
||||
default:
|
||||
$view = $e?BoltView::lookup_id($e->last_view_id):null;
|
||||
if (!$view) {
|
||||
|
@ -298,9 +304,24 @@ default:
|
|||
$iter = new BoltIter($course_doc);
|
||||
$iter->decode_state($view->state);
|
||||
$iter->at();
|
||||
$mode = default_mode($iter->item);
|
||||
$view_id = create_view($user, $course, $iter, $mode, $view->id);
|
||||
show_item($iter, $user, $course, $view_id, $view->id, $mode);
|
||||
$mode = $view->mode;
|
||||
if ($view->item_name == $iter->item->name && ($mode == BOLT_MODE_ANSWER)) {
|
||||
// if we're returning to an answer page,
|
||||
// we need to look up the user's responses and the score.
|
||||
//
|
||||
$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;
|
||||
$view_id = create_view($user, $course, $iter, $mode, $view_orig->id);
|
||||
show_item($iter, $user, $course, $view_id, $view_orig->id, $mode);
|
||||
} else {
|
||||
$view_id = create_view($user, $course, $iter, $mode, $view->id);
|
||||
show_item($iter, $user, $course, $view_id, $view->id, $mode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue