Please can some one help me to mix my quiz questions in this format: fill in the blank, true or false, multiple answers, matching and the rest. please all my questions are stored on the database. any time that I display my question they come in a radio button format.
here is my code:
<?php
if (!isset($_SESSION)){
session_start();
}
include(“database.php”);
//include(“counttime.php”);
extract($
extract($_GET);
extract($
if(isset($subid) && isset($testid))
{
$_SESSION[sid]=$subid;
$
header(“location:quiz.php”);
}
if(!isset($_SESSION[sid]) || !isset($
{
header(“location:index.php”);
}
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “
<html>
<head>
<title>Electronic Exams</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<link href=”quiz.css” rel=”stylesheet” type=”text/css”>
</head>
<body>
<?php
include(“header.php”);
include(“counttime.php”);
//$sql = “SELECT * FROM se_question ORDER BY rand()”;// LIMIT ()”;
$query=”select
$rs=mysql_query(“select * from se_question where test_id=$tid”,$cn) or die(mysql_error());
//this below line displays the student picture as soon as the id is entered
if(!isset($_SESSION[qn]))
{
$_SESSION[qn]=1; //fc
mysql_query(“delete from se_useranswer where sess_id='” . session_id() .”‘”) or die(mysql_error());
$
}
else
{
if($submit==’Next Question’ && isset($ans)) //this codes display the next question when click
{
mysql_data_seek($rs,$_SESSION[qn]);
$row= mysql_fetch_row($rs);
mysql_query(“insert into se_useranswer(sess_id,test_id,que_des,ans1,ans2,ans3,ans4,true_ans,your_ans) values (‘”.session_id().”‘,$tid,’$row[2]’,’$row[3]’,’$row[4]’,’$row[5]’,’$row[6]’,’$row[7]’,’$ans’)”) or die(mysql_error());
if($ans==$row[7])
{
$_SESSION[trueans]+1;
}
$_SESSION[qn]+1;
}
else if($submit==’Get Result’ && isset($ans))
{
mysql_data_seek($rs,$
$row= mysql_fetch_row($rs);
mysql_query(“insert into se_useranswer(sess_id,test_id,que_des,ans1,ans2,ans3,ans4,true_ans,your_ans) values (‘”.session_id().”‘,$tid,’$row[2]’,’$row[3]’,’$row[4]’,’$row[5]’,’$row[6]’,’$row[7]’,’$ans’)”) or die(mysql_error());
if($ans==$row[7])
{
$_SESSION[trueans]=$
}
else{$_SESSION[trueans] =$
}
echo “<h1 class=head1> Result</h1>”;
$_SESSION[qn]=$
echo “<Table align=center><tr class=tot><td>Total Question<td> $_SESSION[qn]”;
echo “<tr class=tans><td>True Answer<td>”.$
$w=$_SESSION[qn]-$
echo “<tr class=fans><td>Wrong Answer<td> “. $w;
echo “</table>”;
mysql_query(“insert into se_result(login, studentid, test_id,test_date,score) values(‘$login’, ‘$studentid’, $tid,'”.date(“Y/m/d”).”‘,$_SESSION[trueans])”) or die(mysql_error());
echo “<h1 align=center><a href=review.php> Review Question</a> </h1>”;
unset($_SESSION[qn]);
unset($_SESSION[sid]);
unset($_SESSION[tid]);
unset($_SESSION[trueans]);
exit;
}
}
$rs=mysql_query(“select * from se_question where test_id=$tid”,$cn) or die(mysql_error());
if (!function_exists(“GetSQLValueString”))
//$sql = “SELECT * FROM se_question ORDER BY rand()”;
$rs=mysql_query(“SELECT DISTINCT
if($_SESSION[qn]>mysql_num_rows($rs)-1)
{
unset($
echo “<h1 class=head1>Please Error Occured</h1>”;
session_destroy();
echo “Please <a href=index.php> Start Again</a>”;
exit;
}
mysql_data_seek($rs,$_SESSION[qn]);//fc
$row= mysql_fetch_row($rs);
//$quiz_shuffle = $
echo “<form name=myfm method=post action=quiz.php>”;
echo “<table width=100%> <tr> <td width=30> <td> <table border=0>”;
$n=$_SESSION[qn]+1;
echo “<tr><td><span class=style2>Q “. $n .”: $row[2]</style>”; //showing the question number plus the question
echo “<tr><td class=style8><input type=radio name=ans value=1>$row[3]”;
echo “<tr><td class=style8><input type=radio name=ans value=2>$row[4]”;
echo “<tr><td class=style8><input type=radio name=ans value=3>$row[5]”;
echo “<tr><td class=style8><input type=radio name=ans value=4>$row[6]”;
function questionTypeNameParseObject($input) {
// your code here.
$this->setState(“”); // Set the state if needed.
return $output;
}
/*if($row[2]=1)
{
echo “<tr><td class=style8><input type=checkbox name=ans1 value=1 checked=checked>$row[3]”;
echo “<tr><td class=style8><input type=textarea name=ans2>”;
echo “<tr><td class=style8><input type=hidden name=ans3 value=3>”;
echo “<tr><td class=style8><input type=hidden name=ans4 value=4>”;
}
if ($_SESSION[qn]+1)
if($_SESSION[qn]<mysql_num_rows($rs)-1)
echo “<tr><td><input type=submit name=submit value=’Next Question’></form>”;
else
echo “<tr><td><input type=submit name=submit value=’Get Result’></form>”;
echo “<tr><td><input type=reset name=Reset value=Reset></form>”;
echo “</table></table>”;
?>
<a href=”quiz_annex.php”>section b</a>
</body>
</html>