1

我正在开发一个在线测验网站,用户可以在其中进行测试(多项选择)。我需要在测试中放置一个计时器说如果测试的制造商将时间设置为 30 分钟,一个计时器将被放置在页面顶部倒计时,现在我想在服务器端监控计时器到 00:00 测试将停止并显示获得的分数。

我考虑过的解决方案:

1) 要使用 JS 插件,并在其到期时执行location.href一些ActionResult将结束测试的操作。

2)要创建一个会话并在给定时间之后并在呈现每个问题之前将其清除,请检查该会话是否已过期。

我对使用基于 javascript 的解决方案的担忧是它的稳健性,我想实现一个服务器端解决方案。请帮助我找到正确的路径...

问候。

4

1 回答 1

1

When using the timer in the browser there is no way to verify that it is running as expected. User can disable javascript and get around your restrictions; heck they can even change your javascript. So relying solely on javascript is not an option.

The best solution is to validate postbacks on server side. You can use javascript on Client side to inform the user so that they are aware of how much time is left and server side to verify they have not gone over the time limit. If synchronization is required, then you can have the javscript ping back every so often to resynch the time.

Expanded Answer The time of the start of the test should be on the server side. Whenever the user clicks begin test or other start buttton to begin their test. The server should note the current time - perhaps in a session or even in database.

The user should then be informed of the time remaining via javascript and expected end time. These are then updated whenever the user submits a question or perform another postback to the server.

The end time will be the fuzzy part. If the javascript does it's job correctly; you can inform the user their test has ended through this (or window.href etc). If the javascript is not worked; then the user will receive their notification whenever they next attempt to submit something to the server.

Either way, the user should clearly be informed that this is the expected end time, and how much time they have remaining on each page load.

于 2012-11-12T17:56:39.873 回答