Mostafa Armandi
Mostafa Armandi

Reputation: 939

Handle task time in asp.net

In an online examination system how could i handle exam elapsed and remaining time.
At the first i managed to solve this problem by using javascript to setup a client side timer in the exam web page at the moment the student come in the exam page and notify server by using ajax in every interval of that timer; so i could update exam duration of current student.
Everything seems OK but the problem becomes apparent when a curious student disables javascript in Browser during exam and re enable it before clicking submit button. hence timer stops and browser could not send ajax requests to the server.
What's the best way to handle this problem ?
Thanks in advance.

Upvotes: 3

Views: 205

Answers (3)

Dennis Traub
Dennis Traub

Reputation: 51634

  • Make sure the page doesn't render with JavaScript disabled (e.g. by only sending a skeleton and filling the actual contents through subsequent Ajax requests)
  • Send one Ajax request as soon as the document has been loaded to start a server-side timer as a backup (and proof) for the client-side timer

Upvotes: 3

Jude Cooray
Jude Cooray

Reputation: 19862

JavaScript can be disabled in the browser and you cannot do anything about it.

However, you can record the start time of the paper somewhere (probably a DB) and when the page is submitted (After a user is finished answering the paper), get the duration that was taken for the question paper to be answered. You know how much time was taken to submit the paper.

Give a grace period of let's say +2 minutes and if the time taken is more than what was allocated, show a message showing "Try again! Next time!".

Upvotes: 2

Rich O'Kelly
Rich O'Kelly

Reputation: 41767

A naive approach would be to include the start time as a form parameter in your web pages, and then calculate the duration based on this time, however this is also subject to curious students using a DOM editing tool to change this value.

You'll need some form of persistence in your application - possibly a database. If you persist the time that the student started you can just use this value when any subsequent requests come in.

Upvotes: 1

Related Questions