I am developing a quiz component in Javascript and I have a startTimer() function in it which starts a countdown based on the value passed to it.
The function is called when the page loads and the quiz starts.
I don’t what users to call the function again and alter the quiz time.
Is it possible to detect that the function is called a second time???
Any user can just disable JavaScript in their browser.
I would suggest that you record the time between the page being served and the answers coming back on the server and use that as the definitive source for how long they took. Perhaps allow a little buffer to compensate for network latency and page rendering time.
The JavaScript timer can be a nice UI feature to help the user know how much time they have left, but never trust a user interface, for a smart user will write his own UI (or in this case, configure the UI to not use JavaScript).