开发者

Timed Quiz: How to consider internet interruptions?

I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time 开发者_运维知识库the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet connection drops, or system crashes/power outages etc.

I need a strategy to figure out when such an accident happened, and stop the clock, then let the user take the test again from where it stopped, and start the clock again.

What is the right strategy? Any help including sample code/examples/ideas are most welcome


Your strategy should depend on importance of the test and ability to retake whole test.

  1. Is test/quiz for fun or competence/knowledge checking?
  2. Are you dealing with logged users?
  3. Are tests generated randomly from large poll of available questions?

these are the questions you need to answer yourself first.

Remember that:

  • malicious user CAN simulate connection outage / power failure,
  • only clock you can trust is one on server side,
  • everything on browser side can be manipulated (think firebug/console js injection)

My approach would be:

  1. Inform users that TIME is important factor and connection issues may not be taken into account when grade will be given...,
  2. Serve only one question, wait for answer, serve another one,
  3. Whole test time should be calculated as SUM of each answer time:
    • save each "question send" / "answer received" timestamps and calculate answer time from it,
    • time between questions wouldn't count,
    • you'd get extra scope on which questions was harder / took longer to answer.
  4. Add some kind of heartbeat to your question page (like ajax request every X seconds), when heartbeat stops you can (depending on options you have):
    1. invalidate question and notify user via dialog that he has connection issues and have to refresh to get new question instead if you have larger poll of questions to use,
    2. pause time on server side (and for example dim question page so user cannot answer until his connection is restored) IMO only for games/fun quiz/tests
    3. save information on server side on each interruption which would later ease decision to allow retake whole test e.g. he was fine until 20th question and then on 3-4 easy questions in a row he was dropping...


The simplest way would be to add a timestamp when the person starts the quiz and then compare that to when they submit. Of course, this doesn't take into account connection drops, crashes, etc... like you mentioned.

To account for these issues I'd probably use something like node.js. Each client has "check-in" when they connect to the quiz. Then at regular intervals (every 1s, 10s, 1m, etc...) the client checks in. If at these intervals the client doesn't check-in you can assume they've had the connection drop. You could keep track of when they connect again and start the timer from where they left off.

This is my initial thought on how to keep track of connection drops and crashes. The same could be done with a front-end ajax call to a Django view.


Either you do the clock on the client side, in which case they can always cheat somehow, or you do it on the server side, and then you aren't taking into account these interruptions.

To reduce cheating somewhat and still allow for interruptions, you could do a 'keep alive'.

Here the client side code announces to the server that it is still there every so often, say every 5 seconds. The server side notes when it stops getting these messages, and pauses/stops the clock. However it still has the start and end time, so you know how long it really took in wall time, and also how long it took while the client was supposedly there.

With these two pieces of information you could very easily track down odd behaviour and blacklist people. Blacklisted people might not be aware that they are blacklisted, but their quiz scores don't show up for other users of your quiz system.


The problem with pausing the clock when the connection to the user drops, is that the user could just disconnect their computer from the internet each time they received a new question, and then reconnect once they had worked out the answer.

One thing you could do, is give the user a certain amount of time for each question.

The clock is started when the user successfully receives the question to their browser, and if the user submits an answer before the time limit, it is accepted, otherwise it is void.

That would mean if a user lost connection it would only affect the question they are currently on. But it would also mean that the user would have no flexibility in how much time they want to allot to each question, you decide for them.

I was thinking you could do something like removing the question from the screen unless the connection to the server was still alive, but the user could always just screen-shot the question before disconnecting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜