2

I have already built an online exam portal, which allows student to take exam online using web browser.

Now in that I also have developed timer function wherein user has to complete the exam within stipulated time frame. What I am getting trouble is that when I refresh the page the timer again start from fresh for example 40 minutes. That is what is problem what I want is when user refresh the page it should not reinstate the timer or same case when they click on next question button.

The context here is Lotus Domino but I want to achieve the things using javascriot, is there anyway we can store the timer value before the page was refreshed or page submitted and when post refreshing / next question it should start from past value..

Thanks hdc

hdc
  • 161
  • 1
  • 13
  • 3
    If JS only just use cookies to start date/time it started. But not going to be perfect people could remove the cookie and reset timer. Back-end solution via session would be more reliable. – GillesC Apr 07 '17 at 10:05
  • I would also use backend if require. – hdc Apr 07 '17 at 11:05
  • Or rather is that possible to prevent user from refreshing the page or clicking on next button using javascript ? – hdc Apr 07 '17 at 11:08
  • I think you should use back-end and Session – Ehsan Nazeri Jun 03 '20 at 16:26

1 Answers1

-1

You can store values either in cookies or better use HTML5 feature of localStorage.

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

Eino
  • 99
  • 3
  • Its an exam portal what if use manipulates and compromises with the timer – Vinod Louis Apr 07 '17 at 10:10
  • For pure JS solution it is a bit hard. You could encrypt the value but to be sure you definitely need a back-end supporting it. – Eino Apr 07 '17 at 10:18