Preclinify / Tickets

2 stars 0 forks source link

[BUG] Investigate too many fetch requests when doing MCQ Endless and end of Exam mode #63

Closed Joecey closed 4 months ago

Joecey commented 4 months ago

Describe the bug

I noticed when doing MCQ Endless, there is a fetch request being done every time you submit an answer. It looks like it's refetching all the questions again if I am not mistaken. would it be possible to minimise the amount of calls that occur?

image

Just as a note, in the case that it is needed so that the answer a user provides is included in the % distribution, I don't think it's critical to do this

highjeans commented 4 months ago

@Joecey I just looked into this. Below is a screenshot of currently what goes through the network from opening the endless page to answering the first question:

Screenshot 2024-07-10 at 12 12 28

The first request to "/endless" is to get the first 10 questions. The next request to "/endless" is to update the database with the user's answered option. The last request to "/endless" is for getting the answer counts.

If you want, I can go ahead and make it so that the answer counts are fetched with all of the question data so that all processing of the user's answer choice (except for updating the database) can be done locally.

Joecey commented 4 months ago

it would probably be the best if it minimises the amount of requests. If you could draft up a PR for this, that would be great!

highjeans commented 4 months ago

For this, should I also minimise the amount of requests in Exam mode? I minimised it in Endless but I believe I will need to do the same in Exam mode.

Joecey commented 4 months ago

Oh wow it is the same! Yes if you could limit the requests in exam mode too that would be great!