E
E
Eugenue Cesarevich2021-04-21 22:44:57
JavaScript
Eugenue Cesarevich, 2021-04-21 22:44:57

How to track if the user aborted the test?

For session storage I use Spring Session and Redis. That is, the session is not stored in memory, but in the database.

There is a user. The user can start taking the test. That is, a question comes from the server, the user gives an answer, and so on until the questions run out. When they run out, you need to write the test result to the database.

The problem is this. I'm going to store the user's responses (for a test that hasn't finished yet) in a session, and the session is stored in Redis. And the user can leave the page, close the tab, etc., and then come back and, if his session is still open, he will pass the test from the middle.

And I want him to pass the test from the very beginning in such cases! How could I reset the test? Pinging comes to mind. I will constantly ping, every 5 seconds I will set the last ping time in the session, and when the user requests a new question, it will check - when was the last ping? If for a long time, then reset the test. But this solution seems to be a crutch.

Does anyone have options?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2018-08-07
@targetologru

maybe the problem is
check without a slash or better yet write the full (absolute) path

A
Alexander Toropov, 2018-08-07
@nefone

You can try sending with the get method:

<script>
$.get(
  "/check.php",
  {
    object: "-120822984"
  },
alert( "Прибыли данные: " + data );
);
</script>

R
Rsa97, 2021-04-21
@Rsa97

You can send all questions from the server at once, show them one by one or in random order on the client, and send all answers at once at the end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question