2007-10-30 22:31:13 +00:00
|
|
|
<?php
|
|
|
|
|
2007-11-29 23:26:49 +00:00
|
|
|
define('BOLT_MODE_SHOW', 0);
|
|
|
|
define('BOLT_MODE_SCORE', 1);
|
|
|
|
define('BOLT_MODE_ANSWER', 2);
|
|
|
|
|
|
|
|
$bolt_ex_mode = 0;
|
|
|
|
$bolt_ex_index = 0;
|
|
|
|
$bolt_ex_state = 0;
|
|
|
|
$bolt_ex_score = 0;
|
|
|
|
|
|
|
|
function bolt_new_seed() {
|
|
|
|
return (float)microtime() * 1000000;
|
|
|
|
}
|
|
|
|
|
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_state; // output if SHOW, else input
|
|
|
|
global $bolt_ex_score; // output if SCORE
|
2007-11-29 16:47:56 +00:00
|
|
|
|
2007-11-29 23:26:49 +00:00
|
|
|
echo "BLAH";
|
|
|
|
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 the answers;
|
|
|
|
// record the RNG seed so that we can do the same shuffle later
|
|
|
|
//
|
|
|
|
$seed = bolt_new_seed();
|
|
|
|
srand($seed);
|
|
|
|
shuffle($choices);
|
|
|
|
$i = 0;
|
2007-11-29 16:47:56 +00:00
|
|
|
foreach ($choices as $choice) {
|
2007-11-29 23:26:49 +00:00
|
|
|
echo "<br><input name=q_$bolt_ex_index type=radio value=$i> $choice\n";
|
|
|
|
$i++;
|
2007-11-29 16:47:56 +00:00
|
|
|
}
|
2007-11-29 23:26:49 +00:00
|
|
|
$bolt_ex_state = $seed;
|
2007-11-29 16:47:56 +00:00
|
|
|
break;
|
|
|
|
case BOLT_MODE_SCORE:
|
2007-11-29 23:26:49 +00:00
|
|
|
$seed = $bolt_ex_state;
|
|
|
|
srand($seed);
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
echo "FOO";
|
2007-11-29 16:47:56 +00:00
|
|
|
break;
|
|
|
|
case BOLT_MODE_ANSWER:
|
2007-11-29 23:26:49 +00:00
|
|
|
$seed = $bolt_ex_state;
|
|
|
|
srand($seed);
|
|
|
|
$right_ans = $choices[0];
|
|
|
|
shuffle($choices);
|
|
|
|
$response = $_GET["q_$bolt_ex_index"];
|
|
|
|
$i = 0;
|
|
|
|
foreach ($choices as $choice) {
|
|
|
|
echo "<br>$choice";
|
|
|
|
if ($response == $i) echo "You chose this";
|
|
|
|
if ($choice == $right_ans) echo "Right answer";
|
|
|
|
$i++;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
?>
|