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-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
|
|
|
|
global $bolt_ex_score; // output if SCORE
|
2007-12-07 23:23:25 +00:00
|
|
|
global $bolt_ex_response; // output if SCORE
|
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);
|
|
|
|
$response = $_GET["q_$bolt_ex_index"];
|
|
|
|
if ($choices[$response] == $right_ans) {
|
|
|
|
$bolt_ex_score = 1;
|
|
|
|
} else {
|
|
|
|
$bolt_ex_score = 0;
|
|
|
|
}
|
2007-12-07 23:23:25 +00:00
|
|
|
$bolt_ex_response = "$bolt_ex_index: $choices[$response]";
|
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);
|
|
|
|
$response = $_GET["q_$bolt_ex_index"];
|
|
|
|
$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
|
|
|
|
global $bolt_ex_score; // output if SCORE
|
|
|
|
global $bolt_ex_response; // output if SCORE
|
|
|
|
|
|
|
|
switch ($bolt_ex_mode) {
|
|
|
|
case BOLT_MODE_SHOW:
|
|
|
|
shuffle($choices);
|
|
|
|
$i = 0;
|
|
|
|
start_table();
|
|
|
|
foreach ($choices as $choice) {
|
|
|
|
$c = $choice[0];
|
|
|
|
row2($c, "<input name=q_".$bolt_ex_index."_$i type=checkbox>");
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
end_table();
|
|
|
|
break;
|
|
|
|
case BOLT_MODE_SCORE:
|
|
|
|
$i = 0;
|
|
|
|
$n = count($choices);
|
|
|
|
$score = 0;
|
|
|
|
shuffle($choices);
|
|
|
|
foreach ($choices as $choice) {
|
|
|
|
$response = $_GET["q_".$bolt_ex_index."_$i"];
|
|
|
|
$r = $choice[1];
|
|
|
|
$correct = ($r && $response) || (!$r && !$response);
|
|
|
|
if ($correct) $score += 1./$n;
|
|
|
|
}
|
|
|
|
$bolt_ex_response = "$bolt_ex_index: $choices[$response]";
|
|
|
|
break;
|
|
|
|
case BOLT_MODE_ANSWER:
|
|
|
|
$i = 0;
|
|
|
|
$n = count($choices);
|
|
|
|
shuffle($choices);
|
|
|
|
start_table();
|
|
|
|
foreach ($choices as $choice) {
|
|
|
|
$c = $choice[0];
|
|
|
|
$response = $_GET["q_$bolt_ex_index_$i"];
|
|
|
|
$r = $choice[1];
|
|
|
|
$correct = ($r && $response) || (!$r && !$response);
|
|
|
|
row2($c, $x);
|
|
|
|
$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
|
|
|
|
global $bolt_ex_score; // output if SCORE
|
|
|
|
|
|
|
|
switch ($bolt_ex_mode) {
|
|
|
|
case BOLT_MODE_SHOW:
|
|
|
|
echo "<img src=$img";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-30 22:31:13 +00:00
|
|
|
?>
|