views:

22

answers:

2

For an online examination system, user actions/answers to be stored and later retrieved if user connection is down.

Which logic should be preferred, client side logic [cookie], or server side logic [Session/Database]?

[Edit]
How user answers will be stored? using specific timer interval for storing user answers? or after specific parts of exam? What is best practice for implementing such solutions?

A: 

As long as you are timing the exam on serverside you can use a cookie to store the data required to remember the options checked. But if the client does not respond even after the duration of the examination is over we would need to invalidate the cookies. I am assuming you submit the data at the end of the exam here.

Cookies are generally used to store user information in most sites with an application form to enhance user experience. Here's a link on implementing Javascript cookies

Mulki
+1  A: 

If you want the answers to be available even when the user connection is down, you need to store them on the client side. If they end up being more than you can fit in a cookie, try a library like PersistJS.

Annie
Using cookie could do the needful, but, how user answers will be written to it? Will this be done each timer interval? or after certain parts of the exam? What is best practice for implementing this?
Ahmed
If it's just a multiple choice exam, I think the easiest thing to do is just listen for events on the form elements (e.g. the onchange for a select or the onclick for a radio button), and persist then answer each time it changes. That way you wont lose data if the browser crashes or the user closes the page.
Annie