Dear all,
I am new group user, computer science graduate; just have joined this established group and thanks to all. I am working in network field but so much interested in web (PHP) field. Recently i am dealling with an educational project like online exam (MCQ) and i am facing some problems for sending radio values to the submitted page.
Every question have 4 possible radio value. Questions are retrieved in the page by matching questions serial form a file and database table. After submission, correct answer is count by only matching the database correct value and selected radio value of each question. So when any user select all the questions correct or wrong way- then my calculation is fully ok. But if any user miss any question, I mean- not select any question then the calculation problem.
Here I feel that if any user doesn't select/ touch any question then that specific question will send a value like 'n' according to serial number, then this problem will be temporarily solved.
But here i think if the comparison is matched by both (serial and correct value vs Serial and users radio value) then the problem will solved efficiently. Here is My Sample code:
Users Question Page:
[code=php]
for ($i = 0 ; $i <= count($sl) ; $i++)
{
$sll=$sl[$i];
$ql = "select * from table_questions where sl = '$sll' && subject='$subje ct' ";
$res = mysql_query($ql ) or die(0);
while ($row = mysql_fetch_arr ay($res,MYSQL_B OTH))
{
$inp11=$inp11+1 ;
$inp=$inp+1;
$inp1="user_val[]".$inp;
print "<TR><TD><b >Q no.".$inp11.": ".$row['question']."</b></TD></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='a'> : </b>".$row['ans1']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='b'> : </b>".$row['ans2']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='c'> : </b>".$row['ans3']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='d'> : </b>".$row['ans4']."</td></TR>";
echo "<input type='hidden' name='db_val[]".$inp11."' value='".$row['correct']."'>";
echo "<input type='hidden' size=30 value='$inp11' name='qsl[$i]'>";
echo "<input type='hidden' size=30 value='$row[sl]' name='qsn[$i]'>";
}
}
print "<input type ='hidden' name='totalq' value='".$inp11 ."' >";
After submission:
$count=0;
for($i=0; $i<$totalq; $i++)
{
if ($user_val[$i]==$db_val[$i])
{
$count+=1;
}
}
[/code]
Would you please give the real solution / modify the code? I am waiting for valuable solution.
Thanks to all
ahm
I am new group user, computer science graduate; just have joined this established group and thanks to all. I am working in network field but so much interested in web (PHP) field. Recently i am dealling with an educational project like online exam (MCQ) and i am facing some problems for sending radio values to the submitted page.
Every question have 4 possible radio value. Questions are retrieved in the page by matching questions serial form a file and database table. After submission, correct answer is count by only matching the database correct value and selected radio value of each question. So when any user select all the questions correct or wrong way- then my calculation is fully ok. But if any user miss any question, I mean- not select any question then the calculation problem.
Here I feel that if any user doesn't select/ touch any question then that specific question will send a value like 'n' according to serial number, then this problem will be temporarily solved.
But here i think if the comparison is matched by both (serial and correct value vs Serial and users radio value) then the problem will solved efficiently. Here is My Sample code:
Users Question Page:
[code=php]
for ($i = 0 ; $i <= count($sl) ; $i++)
{
$sll=$sl[$i];
$ql = "select * from table_questions where sl = '$sll' && subject='$subje ct' ";
$res = mysql_query($ql ) or die(0);
while ($row = mysql_fetch_arr ay($res,MYSQL_B OTH))
{
$inp11=$inp11+1 ;
$inp=$inp+1;
$inp1="user_val[]".$inp;
print "<TR><TD><b >Q no.".$inp11.": ".$row['question']."</b></TD></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='a'> : </b>".$row['ans1']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='b'> : </b>".$row['ans2']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='c'> : </b>".$row['ans3']."</td></TR>";
print "<TR><TD><b><in put type='radio' name='".$inp1." ' value='d'> : </b>".$row['ans4']."</td></TR>";
echo "<input type='hidden' name='db_val[]".$inp11."' value='".$row['correct']."'>";
echo "<input type='hidden' size=30 value='$inp11' name='qsl[$i]'>";
echo "<input type='hidden' size=30 value='$row[sl]' name='qsn[$i]'>";
}
}
print "<input type ='hidden' name='totalq' value='".$inp11 ."' >";
After submission:
$count=0;
for($i=0; $i<$totalq; $i++)
{
if ($user_val[$i]==$db_val[$i])
{
$count+=1;
}
}
[/code]
Would you please give the real solution / modify the code? I am waiting for valuable solution.
Thanks to all
ahm
Comment