Page 1 of 1

Online Exam

Posted: Mon Apr 26, 2010 5:47 am
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.

Re: Online Exam

Posted: Mon Apr 26, 2010 12:14 pm
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']
}

Re: Online Exam

Posted: Mon Apr 26, 2010 2:43 pm
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.