网络<% Language=VBScript %>
<%
set mrs=server.CreateObject("adodb.recordset")
mrs.ActiveConnection="dsn=testsys"
if Request.ServerVariables("http_method")="POST" then
'将学生的回答写入到数据库中
mrs.Source="select * from tbanswer"
mrs.Open,,1,3
mrs.AddNew
mrs("answer")=Request.Form("choose")
mrs("stid")=session("stid")
mrs("questionid")=session("questionid")
mrs.Update
mrs.Close
end if
gotime=hour(now())*60+minute(now())-hour(session("starttime"))*60-minute(session("starttime"))
lefttime=session("testtime")-gotime
if session("page")=cint(session("testnum")) or lefttime<0 then
'如果考试时间已到,关闭数据库对象,并重定向到sevalue.asp文件
set mrs=nothing
Response.Redirect "sevalue.asp"
end if
if Request.ServerVariables("http_method")="GET" then
'已考的题目数
session("page")=1
else
'每做一道题,用“POST”方式提交,已考的题目数+1
session("page")=session("page")+1
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<FORM action="stestmain.asp" method=POST id=form1 name=form1>
<P align=center>
<TABLE border=1 cellPadding=1 cellSpacing=1 width=75%>
<TR>
<TD>
<DIV align=center>第<%=session("page")%>题</DIV></TD></TR>
<TR>
<TD>
<%
'从试题库中取出下一道题
mrs.Source="select * from question where sub='" & session("subname") & "' and teachid='" & session("teachid") & "'"
mrs.Open ,,1,1
mrs.PageSize=1
mrs.AbsolutePage=session("page")
session("questionid")=mrs("questionid")
Response.Write "<PRE>"
Response.Write mrs("question")
Response.Write "</PRE><HR>"
Response.Write "A. " & mrs("A") & "
"
Response.Write "B. " & mrs("B") & "
"
Response.Write "C. " & mrs("C") & "
"
Response.Write "D. " & mrs("D") & "
"
'关闭数据库对象
mrs.Close
set mrs=nothing
%>
</TD></TR>
<TR>
<TD><INPUT id=radio1 name=choose type=radio value=A>A
<INPUT id=radio2 name=choose type=radio value=B>B
<INPUT id=radio3 name=choose type=radio value=C>C
<INPUT id=radio4 name=choose type=radio value=D>D
<INPUT id=submit1 name=submit1 type=submit value=确定>
</TD>
</TR>
</TABLE>
</P>
</FORM>
</BODY>
</HTML>
网络考场(5)(转)stestmain.asp
80酷酷网 80kuku.com