Answer the question
In order to leave comments, you need to log in
How to save answers during testing?
Hi all! I'm writing a testing system and ran into a problem. I need to make a time limit, after which the test will be considered not passed, or it is necessary to pass it again. I can't figure out how to implement this.
After selecting an answer and pressing the "answer" button, the selected answer is immediately entered into the database. It turns out that you need to somehow clear the recorded values after the expiration date, but how to do this is not entirely clear. Of course, you can try to write the responses in cookies.
What other options are there?
Answer the question
In order to leave comments, you need to log in
You can try something like:
quiz_sessions
--------------------
id | user_id | finished(bool) | created_at | finished_at
user_id: ID of the user who is passing the test
finished: did the user finish the passage
created_at: session creation time (beginning of testing)
finished_at: end time
If closing the window means that previously given responses automatically disappear, then sessionStorage .
If it doesn't, then localStorage .
There is also an option with indexedDB , but the support situation is patchy and you will have to deal with polyfills (using Web SQL ).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question