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.
Online Exam
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Online Exam
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
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.
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.