Alternating Sequential User Input Challenge - ASUIC
Posted: Thu Feb 02, 2006 11:20 am
Okay, so I am trying an alternative type of challenge which I have termed - Alternating Sequential User Input Challenge or ASUIC.
Basically, it takes a sequence of letters, or numbers. Randomly takes a selection of these sequences and then randomly removes one of the letters or numbers. Then in a multiple choice format, you are asked the question, "which item is missing?" You will then answer the correct answer.
Well, I can't explain it that good, so here is the code.
This should be pretty hard to scan with an OCR because you have to make a decision that is different every time. I suppose a lucky chance can get it, but seems pretty difficult to me. What do you think?
The output looks like this
Basically, it takes a sequence of letters, or numbers. Randomly takes a selection of these sequences and then randomly removes one of the letters or numbers. Then in a multiple choice format, you are asked the question, "which item is missing?" You will then answer the correct answer.
Well, I can't explain it that good, so here is the code.
Code: Select all
<?php
switch (mt_rand(1,2)){
case 1:
$alphanumeric = "12345678987654321";
break;
case 2:
$alphanumeric = "ABCDEFGHIHGFEDCBA";
break;
}
$str=substr($alphanumeric,mt_rand(0,12), 5);
$random=mt_rand(0,4);
$strTmp=substr($str, 0, $random). "_".substr($str, $random+1, 5-$random);
$missing=substr($str, $random,1);
echo "The sequence: ".$alphanumeric."<br>";
echo "What is missing from this sequence? ".$strTmp."<br>";
echo "Possible Answers: <br><br>";
switch (mt_rand(1,2)){
case 1:
$answer = array("A.) ", "B.) ", "C.) ", "D.) ", "E.) ", "F.) ");
break;
case 2:
$answer = array("1.) ", "2.) ", "3.) ", "4.) ", "5.) ", "6.) ");
break;
}
$placement = mt_rand(0,5);
$limit = count($answer);
for ($i=0; $i<$limit; $i++){
if ($i == $placement){
echo $answer[$i].$missing."<br>";
$correct = $answer[$i].$missing;
}else{
$str=substr($alphanumeric,mt_rand(0,12), 1);
while ($missing == $str){
$str=substr($alphanumeric,mt_rand(0,12), 1);
}
echo $answer[$i].$str."<br>";
}
}
echo "<br><br>Do Your Own Process on This - ".$correct;
?>The output looks like this
The sequence: 12345678987654321
What is missing from this sequence? _7654
Possible Answers:
A.) 4
B.) 1
C.) 7
D.) 8
E.) 3
F.) 6
Do Your Own Process on This - D.) 8