在线考试倒数计时器 [英] Countdown Timer For Online Exam

查看:92
本文介绍了在线考试倒数计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在设计在线考试系统.为此,我需要一个不从头开始的倒数计时器.假设计时器已从40分钟开始,如果用户在20分钟后显示时刷新页面,则计时器将从20分钟起继续.还有另一种情况,如果用户正在参加考试,并且由于任何问题而导致用户无法继续考试,则如果用户再次开始考试,则考试将从他离开考试的地方开始,计时器也会启动从他离开考试的剩余时间开始.

有人可以建议我如何实现目标吗?

谢谢,
Deepak Pandey

Hello,

I am designing Online Examination System. For this I need a count down timer which does not start from beginning. Suppose timer has started from 40 minutes if the user refreshed the page at when the timer showing at 20 minutes then timer will be continue from 20 minutes. And there is also another case if the user is giving the exam and due to any problem if the user not able to continue the exam, if the user again starts the exam then the exam start from where he have left the exam and timer also starts from the remaining time left where he had left the exam.

Can any one suggest how can I achieve the goal.

Thanks,
Deepak Pandey

推荐答案

你好.

Hello.

public static Dictionary<long, User> UserDictionary;








and


public class User
{
    public long ID { get; set; }
    public string Name { get; set; }
    public DateTime StartTime { get; set; }
}



当用户开始考试时,创建一个新的用户实例.然后将该对象添加到静态字典中. (您也可以使用应用程序和会话)




Create a new instance of user when the user starts the exam. then add the object to a static dictionary. (You may also use application and session)


User user = new User()
    {
        ID = 1,
        Name = "Shahin",
        StartTime = DateTime.Now
    };


UserDictionary.Add(user.ID, user);




好的,您可以每次找到每个用户的时间:





Ok, you can find the time of each user every time:


System.TimeSpan userTime = DateTime.Now - UserDictionary[userID].StartTime;



您知道,您必须在Ajax的背景下每秒请求剩余时间".并在每次回复后显示.

祝你好运.



you know, you must request for "Time Left" every second in background by Ajax. and show it after every responsing.

Good luck.


这篇关于在线考试倒数计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆