In my MCQ exam project, I`m maintaining the user answer in session variable, when the exam ends I push the answers in database.
So my question is,
- Should I maintain the answers in session variable?
- When should the answers to be pushe开发者_开发百科d into database
- If I`m maintaining the answer in session(memory), how to straggle with power-failure(lost of session variable), should I use xml file for this purpose?
You answered your own question.
The answer is no, since on power failure the user will end up loosing all his work and won't be very happy.
I think the best thing to do is for you to store the answers on a temp table with a unique identifier (I imagine users have to authenticate before the start the exam). Once they are done, you move the records from the temp table to the actual table.
In conclusion, Session is not a good place. Either a temp storage on your side (temp table) or perhaps a cookie, but you could run into more issues with that...
精彩评论