Hi Everyone,
I am a little perplexed here. I am getting the opposite result from what I am expecting in a switch case. In my quiz I am looping the answers and displaying how the students answered for the teachers. And there is 4 possibilites.
1) They picked the correct answer, echo 'correct answer and your student got this one correct.'
2) They picked the wrong answer, incorrect answer, echo 'incorrect answer and your student chose this.'
3) This was not the correct answer and they did not choose it echo ''.
4) This was the correct answer and they did not choose it echo 'this was the correct answer and they did not choose it'
I am echoing all of these values and the values are correct. IE
$correct[$z] = 53 and $sanswer[$z] = 53 and $ID = 53
Yet, when they got it correct it says "Correct answer. Your student got this one incorrect." and for the incorrect answers it says "Correct answer. Your student got this one correct."
Here is my code...
for($i=1; $i<=4; $i++) {
$ID = key($answer);
echo ' <div style="padding-left:10px">';
echo $answer[$aa].' - correct[z]='.$correct[$z].' $sanswer[$z}='.$sanswer[$z].' $ID='.$ID.'<b>';
switch($ans) {
case ($correct[$z]==$sanswer[$z])&&($ID==$sanswer[$z]):
echo '<font color="#0000FF"> <-- Correct answer. Your student got this one correct.</font></b></div>';
break;
case ($correct[$z]!=$sanswer[$z])&&($ID==$sanswer[$z]):
echo '<font color="#FF00FF"> <-- Correct answer. Your student got this one incorrect.</font></b></div>';
break;
case ($correct[$z]!=$sanswer[$z])&&($ID!=$sanswer[$z]):
echo '<b><font color="#FF0000"> <-- This was your students answer.</font></b>';
break;
case ($correct[$z]==$sanswer[$z])&&($ID!=$sanswer[$z]):
echo '</b></div>';
break;
}
I am confused on this one.
Here is my test page if you want to see what I mean.
Anyone see my error(s)????
Thanks in advance,
Dom