how to do online exam scripting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

how to do online exam scripting

Post by manojsemwal1 »

Somebody help me to develope online exam scripting .
give some link tutorial aur demo script.

thanks
maneetpuri
Forum Commoner
Posts: 60
Joined: Tue Oct 07, 2008 6:32 am

Re: how to do online exam scripting

Post by maneetpuri »

Hi,

If you can tell more about what you need in it then someone might give you some directions.

Or the other (rather better) way is outsource it to some web services firm.

Cheers,
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

1- i want when user take the test the times should be start and the given time the process should be stop.
2- how to evaluate the Result.
3 each and every time when user login randomly question will be select.

Thanks
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: how to do online exam scripting

Post by Jonah Bron »

This should give you some tutorials to start with:

http://lmgtfy.com/?q=php+make+quiz+tutorial
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

thanks for your link .

I had trdied but not get suitable link...
tell me how to evalute the marks when user click on submit button question and answer comes from databases.

thanks
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: how to do online exam scripting

Post by internet-solution »

I am assuming test will consist of multiple choice question (e.g. check boxes, radio buttons or drop down lists). You can simply put them in a form and then post the form to a PHP file. This PHP file will contain code for marking the answers. You will need to store correct answer(s) and mark for each question in the database. Then check user answers with correct answers and add mark to total mark only if they match.

Edit --
You can see an example - one of my early projects
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

Thanks for your reply.............

presently iam using only radio button. and the questions are fetched from database.my code are as follows

Code: Select all

<?php
include 'db.php';

?>
<form name="frm" action="result.php" method="post">
<?php
$page_name="questions.php"; //  If you use this code with a different page ( or file ) name then change this
$start=$_GET['start'];
//echo $start;



//echo $search;
//echo $Affiname;

if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}


$eu = ($start - 0);
$limit = 2;                                 // No of records to be shown per page.
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;

$query2=" select * from questionpaper";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);

    $sql="select * from questionpaper  limit $eu, $limit";
             //echo $sql;
              $rss=mysql_query($sql) or die (mysql_error());
              $count = mysql_num_rows($rss);
              echo '<b>'."Total No of Students -:". $nume.'</b>';
             //echo $count;
             $i=1;
             $n=0;
if($count==0)
 {
       echo"<tr><td colspan=14 bgcolor =#f1ece1><center><strong>Data Not found</td></tr>";

}
      else
{
        while ($b=mysql_fetch_array($rss))
			                {
			                echo "<br>".$i ."".$b[Question]."<br>";
			                echo"<input type='radio' name='q'  value='1'>"."". $b[Ans1]."<br>";
			                echo"<input type='radio' name='q'  value=2''>"."". $b[Ans2]."<br>";
			                echo"<input type='radio' name='q'  value='3'>"."". $b[Ans3]."<br>";
			                echo"<input type='radio' name='q'  value=4''>"."". $b[Ans4]."<br>";
			               $i++;
			               }

}



?>
<input type="submit" value="Finish">
but when i select next question answer then the first question answer is deselect...give some solution. and tell me how to check answer in database.
thanks
Last edited by Benjamin on Mon Jun 07, 2010 7:48 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: how to do online exam scripting

Post by internet-solution »

Yiu are using the same name for all radio buttons (name=q) and they are becoming part of the same radio button group and you can only select one of them. You need to give different name to different questions. Use something like

Code: Select all

while ($b=mysql_fetch_array($rss))
{
echo "<br>".$i ."".$b[Question]."<br>";
echo"<input type='radio' name='q{$i}' value='1'>"."". $b[Ans1]."<br>";
echo"<input type='radio' name='q{$i}' value=2''>"."". $b[Ans2]."<br>";
echo"<input type='radio' name='q{$i}' value='3'>"."". $b[Ans3]."<br>";
echo"<input type='radio' name='q{$i}' value=4''>"."". $b[Ans4]."<br>";
$i++;
}
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: how to do online exam scripting

Post by phdatabase »

The last post suggests adding the value of $i to the name based on the use of {$i}. This is a valid solution, however, if you create an array, you will get the same effect with the bonus of easier back end coding.

echo"<input type='radio' name='q[$i]' value='1'>"."". $b[Ans1]."<br>";
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

Thanks for your valuable reply ya its ok fine. pl help little bit more to try understand.
like ...iam using paging to take exam and set 2 question in each page so when user go back in previous quesions. question are unselected how to select question when user back and how to count the user answers.

thanks ..............
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: how to do online exam scripting

Post by internet-solution »

After a page is posted and the form input values are not retained when user comes back. You will have to fill them in your script. The easiest way will be to store the values is SESSION variables and when the page is loaded check if these variables are set. If yes then populate form input elements from SESSION variables, else keep them blank.

You can also store these values on MySQL database.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

Ya its ok fine .but when user finished the paper and click on submit button then how to post answer in result page while we are using many check box like user select 40 question the the radio box id will 4o. so how to get data from radio boxes.

Thanks.
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: how to do online exam scripting

Post by internet-solution »

As explained in previous posts, you can name the checkbox / radio buttons as arrays, then store them in SESSION variables (again as arrays) between pages and then on the final page when the Submit button is pressed, then do a foreach on the SESSION variables and get the answers. Then you can check against correct answeres and add up the marks for each question.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

Dear
I had tried to put session in radio button but not succedd like
<input type="radio" name="q[$i]" value="1"<?php if($_SESSION['rad_radio']) echo 'checked="checked"'; ?> />
Pl Help how to get value from previous question in result page

thanks

Manoj
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how to do online exam scripting

Post by manojsemwal1 »

Pl Send some suatiable answer to make this.
Post Reply