Online Exam

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

Post Reply
pravin.lohakare
Forum Newbie
Posts: 1
Joined: Mon Apr 26, 2010 5:26 am

Online Exam

Post by pravin.lohakare »

Hi,

I have an online exam application, in this application valid user able to login and appeared for exam. But meanwhile if computer switch off session losses session-id and username, so if user login again exam start from binging.
Please suggest me any solution so that exam will start from the time at which computer switch off in exam.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Online Exam

Post by Jonah Bron »

Save their state/answered questions to the $_SESSION variable. As long as they're not gone too long, you can use the information there to get them back to where they were. Something like this:

Code: Select all

if (isset($_SESSION['question']['like_green_eggs_and_ham'])){
    //question 'like_green_eggs_and_ham' is already answered.  skip it
}else{
    //question has not been answered yet.  ask it
    //put their answer into $_SESSION['question']['like_green_eggs_and_ham']
}
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Online Exam

Post by pickle »

If the browser is closed, $_SESSION can potentially (usually) be lost.

If this is a one page exam, you'll have to use AJAX to store the provided answers on the server. Tie those answers to the exam and the person. The next time they login, load those answers.

If this exam is one question per page, each time they move onto the next question, save the answers they've provided in the database, and retrieve the next time they login.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply