计时程序如何做到在考试过程中防止由于刷新导致时间重新计时和考试结束时间到来前自动提交试卷?
放在Session中与刷新无关
有服务器端判断时间
可用一iframe不断刷新,判断是否到时,如到,则提交
</慕白兄>
如果是统考,把 开始和结束时间存APPLICATION里,隔一段时间提交作业
结合JS,SETTIMEOUT,判断是否到时,到时就提交
<script language="vbscript">
dim timerID
dim timerRunning
dim time1
dim now_time
dim ss_time
dim remanent_time
dim shjian
shjian=<%=sj%>
timeRunning = false
ss_time=0
k=0
function AutoSubmit()
count1.classname="text1"
count2.classname="text1"
count3.classname="text1"
count4.classname="text1"
count5.classname="text1"
if timerRunning then
clearTimeout(timerID)
end if
timerRunning = false
remanent_time=shjian
StarAuto()
end function
function StarAuto()
if k mod 4=0 then
if ss_time=0 then
ss_time=59
remanent_time=remanent_time-1
now_time =timeserial(0,remanent_time,0)
else
ss_time=ss_time-1
end if
time1=formatdatetime(now_time,4)
if ss_time<10 then
time1=cstr(time1)&":0"&ss_time
else
time1=cstr(time1)&":"&ss_time
end if
end if
clock.innerHTML = time1
timerRunning = true
if cdate(time1)>#00:10:00# then
timerID = setTimeout("starauto()",1000)
elseif cdate(time1)>#00:00:01# then
if k mod 2=0 then
clock.style.color = "red"
clock.style.backgroundColor = "#3299cc"
else
clock.style.color = "white"
clock.style.backgroundColor = "#3299cc"
end if
window.status="考试剩余10分钟,请注意抓紧时间"
timerID = setTimeout("starauto()",1000)
elseif cdate(time1)>#00:00:00# then
window.status=""
timerID = setTimeout("starauto()",1000)
else
window.status="考试结束!"
call c(2)
end if
end function
function save_onclick()
if window.Parent.frames("main").document.title="北京一总站考核系统" then
window.Parent.frames("main").frmform.rest_time.value=remanent_time
window.Parent.frames("main").frmForm.submit()
end if
end function
function posit_scroll(posit)
if window.Parent.frames("main").document.title="北京一总站考核系统" then
window.parent.frames("main").document.all.item(posit).scrollintoview(true)
window.parent.frames("main").warning.style.visibility = "visible"
end if
end function
function posit_scroll2()
if window.event.srcElement.className="text1" then
posit=window.event.srcElement.innerHTML
window.parent.frames("main").document.all.item(posit).scrollintoview(true)
end if
end function
function change_color()
if window.event.srcElement.classname ="text1" then
window.event.srcElement.style.color="red"
end if
end function
function restore_color()
if window.event.srcElement.classname="text1" then
window.event.srcElement.style.color="white"
end if
end function
</script>