2007-10-30 22:31:13 +00:00
|
|
|
<?php
|
|
|
|
|
2007-11-29 23:26:49 +00:00
|
|
|
$bolt_ex_mode = 0;
|
|
|
|
$bolt_ex_index = 0;
|
|
|
|
$bolt_ex_state = 0;
|
|
|
|
$bolt_ex_score = 0;
|
2007-12-19 16:31:41 +00:00
|
|
|
$bolt_ex_query_string = "";
|
2007-11-29 23:26:49 +00:00
|
|
|
|
2007-10-30 22:31:13 +00:00
|
|
|
function bolt_exclusive_choice($choices) {
|
2007-11-29 23:26:49 +00:00
|
|
|
global $bolt_ex_mode; // input
|
|
|
|
global $bolt_ex_index; // input
|
2007-12-18 20:28:08 +00:00
|
|
|
global $bolt_ex_score; // incremental output if SCORE
|
2007-12-19 16:31:41 +00:00
|
|
|
global $bolt_ex_query_string;
|
|
|
|
|
|
|
|
parse_str($bolt_ex_query_string);
|
2007-11-29 16:47:56 +00:00
|
|
|
|
2007-11-29 23:26:49 +00:00
|
|
|
switch ($bolt_ex_mode) {
|
2007-11-29 16:47:56 +00:00
|
|
|
case BOLT_MODE_SHOW:
|
2007-11-29 23:26:49 +00:00
|
|
|
shuffle($choices);
|
|
|
|
$i = 0;
|
2007-12-07 23:23:25 +00:00
|
|
|
start_table();
|
2007-11-29 16:47:56 +00:00
|
|
|
foreach ($choices as $choice) {
|
2007-12-07 23:23:25 +00:00
|
|
|
row2($choice, "<input name=q_$bolt_ex_index type=radio value=$i>");
|
2007-11-29 23:26:49 +00:00
|
|
|
$i++;
|
2007-11-29 16:47:56 +00:00
|
|
|
}
|
2007-12-07 23:23:25 +00:00
|
|
|
end_table();
|
2007-11-29 16:47:56 +00:00
|
|
|
break;
|
|
|
|
case BOLT_MODE_SCORE:
|
2007-11-29 23:26:49 +00:00
|
|
|
$right_ans = $choices[0];
|
|
|
|
shuffle($choices);
|
2007-12-18 20:28:08 +00:00
|
|
|
$key = "q_$bolt_ex_index";
|
2007-12-19 16:31:41 +00:00
|
|
|
if (isset($$key)) {
|
|
|
|
$response = $$key;
|
2007-12-18 20:28:08 +00:00
|
|
|
if ($choices[$response] == $right_ans) {
|
|
|
|
$bolt_ex_score += 1;
|
|
|
|
}
|
2007-11-29 23:26:49 +00:00
|
|
|
}
|
2007-11-29 16:47:56 +00:00
|
|
|
break;
|
|
|
|
case BOLT_MODE_ANSWER:
|
2007-11-29 23:26:49 +00:00
|
|
|
$right_ans = $choices[0];
|
|
|
|
shuffle($choices);
|
2007-12-18 20:28:08 +00:00
|
|
|
$key = "q_$bolt_ex_index";
|
2007-12-19 16:31:41 +00:00
|
|
|
if (isset($$key)) {
|
|
|
|
$response = $$key;
|
2007-12-18 20:28:08 +00:00
|
|
|
} else {
|
|
|
|
$response = -1;
|
|
|
|
}
|
2007-11-29 23:26:49 +00:00
|
|
|
$i = 0;
|
2007-12-07 23:23:25 +00:00
|
|
|
start_table();
|
2007-11-29 23:26:49 +00:00
|
|
|
foreach ($choices as $choice) {
|
2007-12-07 23:23:25 +00:00
|
|
|
$x = "";
|
|
|
|
if ($response == $i) $x .= "(You chose this) ";
|
|
|
|
if ($choice == $right_ans) $x .= "(Right answer)";
|
|
|
|
row2($choice, $x);
|
2007-11-29 23:26:49 +00:00
|
|
|
$i++;
|
|
|
|
}
|
2007-12-07 23:23:25 +00:00
|
|
|
end_table();
|
2007-11-29 16:47:56 +00:00
|
|
|
break;
|
2007-10-30 22:31:13 +00:00
|
|
|
}
|
2007-11-29 23:26:49 +00:00
|
|
|
$bolt_ex_index++;
|
2007-10-30 22:31:13 +00:00
|
|
|
}
|
2007-12-01 22:43:11 +00:00
|
|
|
|
2007-12-10 22:13:48 +00:00
|
|
|
function bolt_inclusive_choice($choices) {
|
|
|
|
global $bolt_ex_mode; // input
|
|
|
|
global $bolt_ex_index; // input
|
2007-12-18 20:28:08 +00:00
|
|
|
global $bolt_ex_score; // incremental output if SCORE
|
2007-12-19 16:31:41 +00:00
|
|
|
global $bolt_ex_query_string;
|
|
|
|
|
|
|
|
parse_str($bolt_ex_query_string);
|
2007-12-10 22:13:48 +00:00
|
|
|
|
|
|
|
switch ($bolt_ex_mode) {
|
|
|
|
case BOLT_MODE_SHOW:
|
|
|
|
shuffle($choices);
|
|
|
|
$i = 0;
|
|
|
|
start_table();
|
|
|
|
foreach ($choices as $choice) {
|
|
|
|
$c = $choice[0];
|
2007-12-18 20:28:08 +00:00
|
|
|
row2("<input name=q_".$bolt_ex_index."_$i type=checkbox>", $c);
|
2007-12-10 22:13:48 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
end_table();
|
|
|
|
break;
|
|
|
|
case BOLT_MODE_SCORE:
|
|
|
|
$i = 0;
|
|
|
|
$n = count($choices);
|
|
|
|
$score = 0;
|
|
|
|
shuffle($choices);
|
|
|
|
foreach ($choices as $choice) {
|
2007-12-12 04:43:04 +00:00
|
|
|
$key = "q_".$bolt_ex_index."_$i";
|
2007-12-19 16:31:41 +00:00
|
|
|
$response = isset($$key);
|
2007-12-10 22:13:48 +00:00
|
|
|
$r = $choice[1];
|
|
|
|
$correct = ($r && $response) || (!$r && !$response);
|
|
|
|
if ($correct) $score += 1./$n;
|
2007-12-18 20:28:08 +00:00
|
|
|
$i++;
|
2007-12-10 22:13:48 +00:00
|
|
|
}
|
2007-12-18 20:28:08 +00:00
|
|
|
$bolt_ex_score += $score;
|
2007-12-10 22:13:48 +00:00
|
|
|
break;
|
|
|
|
case BOLT_MODE_ANSWER:
|
|
|
|
$i = 0;
|
|
|
|
$n = count($choices);
|
|
|
|
shuffle($choices);
|
|
|
|
start_table();
|
2007-12-18 20:28:08 +00:00
|
|
|
table_header("Choice", "Correct?", "Your answer");
|
2007-12-10 22:13:48 +00:00
|
|
|
foreach ($choices as $choice) {
|
|
|
|
$c = $choice[0];
|
2007-12-12 04:43:04 +00:00
|
|
|
$key = "q_".$bolt_ex_index."_$i";
|
2007-12-19 16:31:41 +00:00
|
|
|
$response = isset($$key);
|
2007-12-10 22:13:48 +00:00
|
|
|
$r = $choice[1];
|
|
|
|
$correct = ($r && $response) || (!$r && !$response);
|
2007-12-18 20:28:08 +00:00
|
|
|
table_row($c, $r?"yes":"no", $response?"yes":"no");
|
2007-12-10 22:13:48 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
end_table();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$bolt_ex_index++;
|
|
|
|
}
|
|
|
|
|
2007-12-01 22:43:11 +00:00
|
|
|
function bolt_image_rect($img, $rect) {
|
|
|
|
global $bolt_ex_mode; // input
|
|
|
|
global $bolt_ex_index; // input
|
|
|
|
global $bolt_ex_state; // output if SHOW, else input
|
2007-12-18 20:28:08 +00:00
|
|
|
global $bolt_ex_score; // incremental output if SCORE
|
2007-12-01 22:43:11 +00:00
|
|
|
|
2007-12-19 16:31:41 +00:00
|
|
|
parse_str($bolt_ex_query_string);
|
|
|
|
|
2007-12-01 22:43:11 +00:00
|
|
|
switch ($bolt_ex_mode) {
|
|
|
|
case BOLT_MODE_SHOW:
|
|
|
|
echo "<img src=$img";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-30 22:31:13 +00:00
|
|
|
?>
|