Hi, I'm creating a quiz application,I'm displaying one question per page and after the user clicks next i increnent a counter which is used to iterate over the collection of Question objects,and the next Question with options is displayed...I also want a previous functionality so i have a Previous button in the JSP,when i click the previous button i decrement the counter and the Page is generated again.But i want to retain the user's options.
You could save his/her options in session scope or the database and then display them again. I think it would be better if the client browser handles what question should be chosen next with the use of parameters (hidden if necessary). That way you dont have to increment or decrement counts, unless of course the collection of questions is generated randomly.
In my online exam applications I create an object to hold each user's information - present question number, answers so far, indexes of each question in the main question script, etc. - Naturally the reference to the object is stored in the session and thats the only thing that is stored there. This approach lets the user move backwards and forwards through the test, jump to a marked question, etc.
By making the object Serializable you have the possibility of saving and resuming the test.
Joined: Feb 07, 2007
Thanks Bill and John, I will try it out using Bill's approach and get back to you.