Javascript 中基于时间的评分系统

发布于 2024-08-19 13:00:41 字数 360 浏览 4 评论 0原文

我使用了 jQuery 脚本 以便在我所在的 php 页面上有一个倒计时脚本正在做,但我还希望有一个基于用户回答某些问题所花费的时间的评分系统。

我正在使用一些拖放操作,然后单击某个链接进入图像地图 - 这是网页中唯一正确的链接 - 在三个页面中我正在使用此倒计时,但我想,一旦用户完成拖放或单击链接,当用户单击“提交”按钮时获取倒计时的数字......但我什至不确定我是否可以做到这一点。

或者,我可以使用任何倒计时脚本来获取用户单击提交按钮时显示的实际数字吗?

提前非常感谢大家!

I have used a jQuery script in order to have a countdown script on a php page that I am doing, but I would also like to have a score system in it based on the time the user takes to answer some questions.

I am using some drag and drops and click in a certain link into an image map -which is the only correct link in the webpage- and in the three pages I am using this countdown, but I would like to, once the user has completed the drags&drops or clicked the links, get the number on the countdown just when the user clicked on a "submit" button...but I am not even sure if I can do this.

Alternatively, could I use any countdown script that would let me get the actual number that is being showed just when the user click on the submit button?

Thanks a lot everybody in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆啦不做梦 2024-08-26 13:00:41

仅将 javascript 倒计时用于显示目的,您不能信任客户端。

在服务器端保持倒计时。将其存储在 SESSION 变量或数据库中。

JavaScript 是不安全的,因为客户端可以更改它。我可以将您的页面保存在我的计算机上,打开它,然后修改计时器的报告方式,您会得到与应有的时间完全不同的时间。我也可以使用浏览器地址栏更改变量。客户端总是可以改变 JavaScript 中的任何东西,并且你必须、绝对必须依赖服务器来保证用户的诚实。

Only use the javascript countdown for display purposes, you cannot trust the client.

Keep the count down server side. Store it in the SESSION variable, or in the database.

Javascript is insecure because the client can change it. I could save your page on my machine, open it up, and modify how the timer reports and you'd get a completely different time than you should get. I could also just change the variable using the browsers address bar. The client can always, always change anything in javascript, and you must, absolutely must rely on the server to keep your users honest.

花桑 2024-08-26 13:00:41

当您希望计时器启动时,为什么不直接存储时间(作为数值),然后在您想知道已经过了多长时间时检查差异?换句话说,您已经获得了客户端计算机的时钟计数,因为这就是时钟的作用。只需记住拖放完成的时间(或作为参考的任何时间点),然后在提交按钮的事件处理程序中再次检查时间。

Why not just stash the time (as a numeric value) when you want the timer to start, and then just check the difference when you want to know how long it's been? In other words, you've already got the client computer's clock counting, because that's what clocks do. Just remember what time it was when the drag&drop completes (or whatever point in time serves as your reference), and then check the time again in an event handler for the submit button.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文