D
D
Diamond2015-06-01 16:48:00
PHP
Diamond, 2015-06-01 16:48:00

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

2 answer(s)
D
D', 2015-06-01
@Arios

You can try something like:

quiz_sessions
--------------------
id | user_id | finished(bool) | created_at | finished_at

Where:
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

Now, when the user starts the test, we create a new quiz_sessions entry in the database.
If the database already has a NOT finished session, you can offer the user to continue the last test from the moment where he stopped.
When the user finishes, we update the record in the database, and set finished & finished_at .
Next, you can make a script that will run through quiz_sessions in cron and delete records that have created_at > some value + you can delete all responses from the user.
UPD:
What is the advantage of this approach:
If we do not delete sessions that are not finished, then we can make a selection and see how many people and who specifically started doing the test and did not finish. We can send them a notice or punish them.
You can make a selection and show the statistics of the top test time + average time + minimum.
You can catch "cheaters", if there are any, who will pass the test in 1 second.

E
Evgeny Petrov, 2015-06-01
@Petroveg

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 question

Ask a Question

731 491 924 answers to any question