multiple chocie coding??
Posted: Wed Nov 12, 2003 5:59 am
hey everybody. I am currently doing a web project using php and mysql. i have never used these languages before so I'm quite lost. Basically the code i am working on at the moment is a multiple choice exam. the code for marking it is as follows;
<?php
$_SCORE=0;
if($_POST["r1"]=='red'){
$_SCORE++;
}
if($_POST["r2"]=='red'){
$_SCORE++;
}
if($_POST["r3"]=='red'){
$_SCORE++;
}
if($_POST["r4"]=='red'){
$_SCORE++;
}
if($_POST["r5"]=='red'){
$_SCORE++;
}
if($_POST["r6"]=='red'){
$_SCORE++;
}
if($_POST["r7"]=='red'){
$_SCORE++;
}
if($_POST["r8"]=='red'){
$_SCORE++;
}
if($_POST["r9"]=='red'){
$_SCORE++;
}
if($_POST["r10"]=='red'){
$_SCORE++;
}
if($_SCORE==0){
print("Sorry you got them all wrong!");
}
else if($_SCORE==10){
print("Congratulations you got them all right!!");
}
else if ($_SCORE<4){
print (" Sorry you failed!");
?>
<br/>
<?php
print("Your score is: ");
print($_SCORE);
}
else {
print("Your score is: ");
print($_SCORE);
?>
<br/>
<?php
print (" congratulations you passed!");
}
?>
<html>
<head>
<body>
<p><a href="http://www.registerhome.com/~schubert/test3.html"><font color="#0000FF"><u>Take
the test again.</u></font></a></p>
</html>
</head>
</body>
i have the html code in a seperate file. my problem is that i want to ensure that users can only sit the exam at max 3 times before they have to resit the tutorial that leads up to it, any ideas??
Sorry if i haven't made my problem very clear, but any ideas ye have would be greatly appreciated!!
Thanks,
Suzie
<?php
$_SCORE=0;
if($_POST["r1"]=='red'){
$_SCORE++;
}
if($_POST["r2"]=='red'){
$_SCORE++;
}
if($_POST["r3"]=='red'){
$_SCORE++;
}
if($_POST["r4"]=='red'){
$_SCORE++;
}
if($_POST["r5"]=='red'){
$_SCORE++;
}
if($_POST["r6"]=='red'){
$_SCORE++;
}
if($_POST["r7"]=='red'){
$_SCORE++;
}
if($_POST["r8"]=='red'){
$_SCORE++;
}
if($_POST["r9"]=='red'){
$_SCORE++;
}
if($_POST["r10"]=='red'){
$_SCORE++;
}
if($_SCORE==0){
print("Sorry you got them all wrong!");
}
else if($_SCORE==10){
print("Congratulations you got them all right!!");
}
else if ($_SCORE<4){
print (" Sorry you failed!");
?>
<br/>
<?php
print("Your score is: ");
print($_SCORE);
}
else {
print("Your score is: ");
print($_SCORE);
?>
<br/>
<?php
print (" congratulations you passed!");
}
?>
<html>
<head>
<body>
<p><a href="http://www.registerhome.com/~schubert/test3.html"><font color="#0000FF"><u>Take
the test again.</u></font></a></p>
</html>
</head>
</body>
i have the html code in a seperate file. my problem is that i want to ensure that users can only sit the exam at max 3 times before they have to resit the tutorial that leads up to it, any ideas??
Sorry if i haven't made my problem very clear, but any ideas ye have would be greatly appreciated!!
Thanks,
Suzie