考試系統時間自動控制程式

hbhuang發表於2007-11-13

下面是考試的時間自動控制程式(便於演示只設了60秒鐘,實際應用應以系統調出試卷的考試時間為準!):
<SCRIPT language=JavaScript>
<!-- Write by HEKAI for TestTimeContorl
var timerID = null;var timerRunning = false
var stardate = new Date();var startime = gettotalsecond(stardate)
var totaltime = 60; var lasttime;var facetime
function Stepclock(){

[@more@]

// hk made by himself
if(timerRunning)
clearTimeout(timerID)
timerRunning = false }
function startclock(){
Stepclock();showtime() }
function gettotalsecond(getdate){
var hours = getdate.getHours()
var minutes = getdate.getMinutes();var seconds = getdate.getSeconds()
var gettotalsecond = seconds + minutes * 60 + hours * 3600
return(gettotalsecond) }
function showtime(){
var now = new Date();var timeValue = gettotalsecond(now)
document.clock.face.value = timeValue - startime
facetime = document.clock.face.value;lasttime = totaltime - facetime
document.clock.sytime.value = lasttime
timerID = setTimeout("showtime()",1000)
timerRunning = true
if (lasttime == 20){
for(i=1;i<=3;i++){
alert('考試時間只剩下最後20秒!')}}
if (lasttime == 0){
for(i=1;i<=5;i++){
alert('時間完畢!請迅速交卷!!')}}
if (lasttime == -10){
for(i=1;i<=10;i++){
alert('考試時間超過10秒,關閉此視窗!')}}
}//-->
</SCRIPT>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10291852/viewspace-982325/,如需轉載,請註明出處,否則將追究法律責任。

相關文章