?? testing.asp
字號:
<%
option explicit
Response.expires=-1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","no-store"
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>考試</title>
<style>
td {
font-size:14px;
line-height:18px;
}
input.btn {
background:#000000;
color:#FFFFFF;
border:1px #FFFFFF solid;
}
</style>
</head>
<body>
<%
dim rsTest,strSqlTest,rsTemp,strSqlTemp,rsPS,strSqlPS,intPrjID,intPSID,intStudentID
dim intTotalMark,intSSCount,intSSMark,intMSCount,intMSMark,intBCount,intZGCount,intBMark,intZGMark
dim strPrjName,dtmStartTime,intLimitTime,intState,dtmStartDate,dtmEndDate
if checkStudentLogin() = false then '驗證考生是否已登錄
response.redirect "student_login.asp"
end if
intPrjID = CLng(request.querystring("prjid"))
intStudentID = request.cookies("aoyi")("studentid")
'讀取考試信息
strSqlTest = "select starttime,endtime,limittime,prjname,ss_count,ms_count,b_count,zg_count from project where prjid=" & intPrjID
set rsTest = server.createobject("ADODB.Recordset")
rsTest.open strSqlTest,G_CONN,1,1
'驗證是否存在本次考試
if rsTest.bof and rsTest.eof then
response.write "<script>alert('此次考試不存在!');window.open('index_main.asp','_self');</script>"
rsTest.close
set rsTest = nothing
response.end
end if
strPrjName = rsTest("prjname")
intSSCount = rsTest("ss_count")
intSSMark = intSSCount
intMSCount = rsTest("ms_count")
intMSMark = intMSCount * 2
intBCount = rsTest("b_count")
intBMark = intBCount
intZGCount= rsTest("zg_count")
intZGMark = intZGCount * 10 '主觀題分數
intTotalMark = intSSMark + intMSMark + intBMark + intZGMark
dtmStartDate = rsTest("starttime")
dtmEndDate = rsTest("endtime")
intLimitTime = rsTest("limittime")
rsTest.close
'驗證現在是否在可考試時間內
if now() < dtmStartDate or now() > dtmEndDate + 1 then
response.write "<script>alert('現在不在考試計劃時間內!');window.open('index_main.asp','_self');</script>"
set rsTest = nothing
response.end
end if
'驗證現在是否有其他正在進行的考試
if G_CONN.execute("select count(*) as reccount from prj_student where prjid<>" & intPrjID & " and studentid=" & intStudentID & " and state=2")("reccount") > 0 then
response.write "<script>alert('你有其他考試正在進行中,不能同時進行兩次考試!');window.open('index_main.asp','_self')</script>"
set rsTest= nothing
response.end
end if
'取得本考生本次考試的狀態
set rsTemp = server.createobject("ADODB.Recordset")
strSqlTemp = "select state from prj_student where prjid=" & intPrjID & " and studentid=" & intStudentID
rsTemp.open strSqlTemp,G_CONN,1,1
if rsTemp.bof and rsTemp.eof then
intState = 0
else
intState = rsTemp("state")
end if
rsTemp.close
set rsTemp = nothing
if intState = 1 then
response.write "<script>alert('你已經參加過此次考試了,不能再次參加此次考試!');window.open('index_main.asp','_self');</script>"
set rsTest = nothing
response.end
elseif intState = 0 then '當考生第一次參加此次考試時進行考生的初始化,生成試卷等操作
'生成試卷
if makePaper(intPrjID,intStudentID) = false then
Response.Write "<script>alert('生成試卷失敗!');window.open('index_main.asp','_self');</script>"
set rsTest = nothing
Response.End
end if
'在prj_student增加相應的考生考試記錄
strSqlPS = "select * from prj_student where prjid=" & intPrjID & " and studentid=" & intStudentID
set rsPS = server.createobject("ADODB.Recordset")
rsPS.open strSqlPS,G_CONN,1,3
if rsPS.bof and rsPS.eof then
rsPS.addnew
rsPS("prjid") = intPrjID
rsPS("studentid") = intStudentID
rsPS("state") = 2
rsPS("starttime") = now()
rsPS.update
else
rsPS("state") = 2
rsPS("starttime") = now()
rsPS.update
end if
rsPS.close
set rsPS = nothing
end if
'取得考試的開始時間
dtmStartTime = G_CONN.execute("select starttime from prj_student where prjid=" & intPrjID & " and studentid=" & intStudentID)("starttime")
'判斷當前是否在考試時間內
if DateDiff("n",dtmStartTime,now()) > intLimitTime then
response.write "<script>alert('本次考試時間已過,不能再進行考試!');window.open('index_main.asp','_self');</script>"
set rsTest = nothing
response.end
end if
%>
<script language="jscript">
var dtmStartTime,intLimitTime
dtmStartTime = new Date(<%=Year(dtmStartTime)%>,<%=Month(dtmStartTime)%>,<%=Day(dtmStartTime)%>,<%=Hour(dtmStartTime)%>,<%=Minute(dtmStartTime)%>,<%=Second(dtmStartTime)%>);
intLimitTime = <%=intLimitTime%>;
function floatTestInfo() //控制浮動信息板在右下方顯示
{
var targetPosTop,targetPosLeft
targetPosTop = document.body.scrollTop + document.body.clientHeight - 100;
targetPosLeft = document.body.clientWidth + document.body.scrollLeft - 190;
document.all.divTestInfo.style.posTop = document.all.divTestInfo.style.posTop + (targetPosTop - document.all.divTestInfo.style.posTop) * .2
document.all.divTestInfo.style.posLeft = document.all.divTestInfo.style.posLeft + (targetPosLeft - document.all.divTestInfo.style.posLeft) * .2
setTimeout('floatTestInfo();',50);
}
function ctrlTestTime() //控制考試時間
{
var dtmCurrentTime = new Date();
//控制時間的顯示
txtOddTime.value = intLimitTime - ((dtmCurrentTime.getHours() - dtmStartTime.getHours()) * 60 + dtmCurrentTime.getMinutes() - dtmStartTime.getMinutes());
if(txtOddTime.value < 10)
{
txtOddTime.style.color = '#FF3300';
}
//在考試時間結束時進行交卷
if(txtOddTime.value == 0)
{
alert('考試時間已到,強制進行交卷!');
window.open('testfinish.asp?action=submitexam&prjid=<%=intPrjID%>&studentid=<%=intStudentID%>','_self');
}
window.setTimeout('ctrlTestTime();',1000);
}
function submitExam() //交卷
{
if(txtOddTime.value < 30)
{
alert('考試時間沒到半小時,不得交卷!');
}
if(confirm('一旦交卷就不能再進行答題,你確認要交卷嗎?')==true)
window.open('testfinish.asp?action=submitexam&prjid=<%=intPrjID%>&studentid=<%=intStudentID%>','_self');
}
function saveAnswer(objAnswer) //保存試題答案
{
if(objAnswer.type == 'checkbox') //如果是多選題剛分為選中或取消選中兩種操作
{
if(objAnswer.checked == true)
window.open('test_saveanswer.asp?isTxt=0&action=selected&answer=' + objAnswer.value + '&id=' + objAnswer.name,'fraSaveAnswer');
else
window.open('test_saveanswer.asp?isTxt=0&action=selectcancel&answer=' + objAnswer.value + '&id=' + objAnswer.name,'fraSaveAnswer');
}
if (objAnswer.type == 'radio')
{
window.open('test_saveanswer.asp?isTxt=0&answer=' + objAnswer.value + '&id=' + objAnswer.name,'fraSaveAnswer')
}
else
{
window.open('test_saveanswer.asp?isTxt=1&answer=' + objAnswer.value + '&id=' + objAnswer.name,'fraSaveAnswer')
//alert(objAnswer.name);
}
objAnswer.focus();
}
</script>
<script for=window event=onload language="JScript">
//在頁面裝載以后啟動考試時間控制與控制面板浮動控制功能
floatTestInfo();
ctrlTestTime();
</script>
<iframe name="fraSaveAnswer" style="visibility:hidden;height:0px" src=""></iframe>
<!--考試控制面板開始-->
<div name="divTestInfo" id="divTestInfo" style="position:absolute;border:solid 0px #000;left:200px;width:180px;height:80px">
<table width="100%" height="50" align="center" border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="1">
<tr>
<td colspan="2" align="center" bgcolor="#000000"><font color="#FFFFFF"><strong>控制面板</strong></font></td>
</tr>
<tr>
<td align="right" width="100" bgcolor="#000000">
<font color="#FFFFFF">考試總時間:</font>
</td>
<td bgcolor="000000" align="right">
<font color="#DDFF00"><strong><%=intLimitTime%></strong></font> <font color="#FFFFFF">分鐘 </font>
</td>
</tr>
<tr>
<td align="right" bgcolor="#000000">
<font color="#FFFFFF">剩余時間:</font>
</td>
<td bgcolor="#000000" align="right" height="20">
<input name="txtOddTime" type="text" size="3" readonly="" style="text-align:right;color:#AAFF00;border:0px solid #000000;background:#000000;font-weight:bold;" value="<%=intLimitTime-DateDiff("n",dtmStartTime,now())%>">
<font color="#FFFFFF">分鐘 </font>
</td>
</tr>
<tr>
<td colspan="2" height="30" align="center" bgcolor="#000000">
<input onClick="submitExam();" class="btn" type="button" value=" 交 卷 ">
</td>
</tr>
</table>
</div>
<!--考試控制面板結束-->
<table width="550" align="center" border="0" cellspacing="5" cellpadding="5">
<tr>
<td align="center" height="40">
<font size="4"><strong><%=strPrjName%></strong></font>
</td>
</tr>
<tr>
<td align="center">
姓名:<%=request.cookies("aoyi")("studentname")%> 總分:<%=intTotalMark%> 考試時間:<%=intLimitTime%>分鐘
</td>
</tr>
<tr>
<td><hr size="1" width="95%" color="#CCCCCC"></td>
</tr>
<%
'顯示單項選擇題
strSqlTest = "select P_P.id,P_P.answer,P_P.orderid,S.content,S.option1,S.option2,S.option3,S.option4,S.option5,S.option6 from prj_process P_P,subject S where S.type=1 and P_P.subid=S.id and P_P.studentid=" & intStudentID & " and P_P.prjid=" & intPrjID & " order by P_P.orderid"
rsTest.open strSqlTest,G_CONN,1,1
if not rsTest.bof and not rsTest.eof then
%>
<tr>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -