Online exam time issue

hi there
i have a problem with online exam time that will be manage during the exam by ajax.
in each ajax request, i will send the remain time and store it in a db table.
the problem is if i use short intervala for exam send request every one second, it’s so heavy for the server and if use longer intervals like 10 seconds gap between each ajax request, use can hit refresh and dont let time to change

what can i do?
thanks in advance.

How I would solve that:

Server:

  • When exam is started, store current server’s timestamp as start_time
  • Mark exam as started by setting is_started flag to true
  • Pass current server’s timestamp (current_time) and start_time to client while rendering exam page

Client:

  • Calculate remaining time using current_time and start_time received from server (remaining_time = current_time - start_time). Don’t use client’s own current time as it can be in different timezone.
  • Show countdown timer;
  • Don’t send any time requests to server at all, they’re useless;
  • If time is out, redirect client somewhere (or do whatever you want)

If user refreshes the page nothing bad will happen, because server see that exam is already in progress (is_started == true) and just sends new current_time and old start_time to client. So client calculates remaining time again and get the same amount as before refreshing.

When user ends exam (submits form):
Server:

  • Check is_started == true
  • Check time() - start_time is less than allowed time limit
  • If any of checks above is not true, show error and don’t accept user answers
  • Save user answers
  • Set is_started flag to false

Those two checks will not allow user to block countdown timer in his browser, because actual time counting is handled by server and client shows timer only for user’s convenience.

1 Like

thanks a lot
so how handle those kind of users that faced with problem during the exam and want to continue the exam after their problems, the problems can be unexpectedly restart the computer, or internet connection fail etc etc

It’s up to you how to handle such situations
In general you may have some “restart” action that will clear is_started flag and shuffle questions in the quiz or something like that.

Yes, they will be same on the first run.
Actual expression to get remaining time will look like

time_passed = current_time - start_time
time_remain = time_allowed - time_passed

Oops, answered to the deleted post :smiley:

so in solutions like that, if user cant comeback before time limit, he couldnt continue his exam! :frowning:
is there anyway to handle it?

yes, sorry. because i got your mean a little late, at the time you replied me. :wink:

So you are wanting to allow something like
stuck
pause exam
research to find answer
resume exam

i.e. more like an untimed “open book” exam?
If so, why monitor time at all?

i dont know maybe you are right, but its a practical exam to imporve student skills without giving liscense, but time limit is regular in all exams.

anyway i will accept any better solution for developing the exam

thanks in advance

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.