E
E
Eugenue Cesarevich2021-02-07 17:03:47
Java
Eugenue Cesarevich, 2021-02-07 17:03:47

How to store session related data?

I want to make a student testing application on Spring MVC, Spring DataJPA, Hibernate stack.

Testing will be unusual. When a student starts the test, an array of questions is generated for him. If a student incorrectly answers a question, then more questions on this topic should be added to the end of this array.

Example:

A student starts testing on the topic "Cats". An array is formed with the following questions:

"Кошки мяукают?"
"У кошек бывают котята?"
"Кошки едят грибы?"

The student correctly answered the question "Do cats meow?". Then the student incorrectly answered the question "Do cats have kittens?", so in-depth questions on this topic are added to the end of the array, now the array looks like this:
"Кошки мяукают?"         // Ответил верно
"У кошек бывают котята?" // Ошибка!
"Кошки едят грибы?"
"Котята бывают у кошек?" // Добавлено после ошибки
"Котята - это кошки?"    // Добавлено после ошибки

Thus, the test grows if the student makes many mistakes, which allows you to find the very first gaps in the topic.

I have a question about the implementation of such a system. It turns out that a list of questions should be stored somewhere, to which new questions should be added, in case the student makes a mistake. As far as I understand, I have to bind this list to the session. Is it even possible to store a list of questions directly in the session? It's just that a student needs only one question at a given time, and if I store the entire list of questions in a session, won't that load the system too much?

If such a list can be stored directly in the session, then what classes / methods should I call to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mark Struchkov, 2021-02-19
@upagge

Is it possible to store the list directly in the session? Perhaps, but it's not entirely clear why. The session is not meant for that. There you can store some attributes about the user that will help in authorization, for example, his group, ip, identifier.
You can simply make a service that will store a temporary list of questions, for example, based on Map

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question