lt; TABLE align=center border=1 cellPadding=1
cellSpacing=1
width="80%" >
< TR >
< TD style="WIDTH: 50%" width="50%"
< INPUT name=ans< %=i% > type=radio value="A" >
< %=rs("a")% >< /TD >
< TD >< INPUT name=ans< %=i% >
type=radio value="B" >
< %=rs("b")% >< /TD >< /TR >
< TR >
< TD >< INPUT name=ans< %=i% >
type=radio value="C" >
< %=rs("c")% >< /TD >
< TD >< INPUT name=ans< %=i% >
type=radio value="D" >
< %=rs("d")% >< /TD >
< /TR >
< /TABLE >
< %
i=i+1
rs.movenext
loop
% >
< /P >
< P > < /P >
< P align=center >< INPUT id=submit1 name=submit1
type=submit
value=Submit >< INPUT id=reset1 name=reset1
type=reset value=Reset >< /P >< /FORM >
< /BODY >
< /HTML >
‘result.asp源
程序,对用户答卷评分,
并将分数记录入库
< %@ Language=VBScript % >
< HTML >
< HEAD >
< META NAME="GENERATOR" Content="Microsoft
Visual Studio 6.0" >
< /HEAD >
< BODY >
< P > < /P >
< %
name=session(“user”)
dim score
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver=
{Microsoft Access Driver (*.mdb)};dbq="
& Server.MapPath("exercise.mdb")
sql="select ans from test"
Set rs = conn.Execute( sql )
ycorrect=0
rsCount=0
‘给出正确
答案并评分
Response.Write "正确
答案:"
Do while not rs.eof
Response.Write rs("ans")
rsCount=rsCount+1
if Request.Form(rsCount)=rs("ans") then
ycorrect=ycorrect+1
end if
rs.movenext
loop
Response.Write "< br >你的
答案:"
score=int(ycorrect/rscount*100)
for i=1 to Request.Form.Count-1
Response.Write Request.Form(i)
next
Response.Write "< br >"
Response.Write "你的成绩:"&score
if score< 60 then Response.Write " 你不及格!"&"< br >"
else if score >=60 Response.Write " 及格"&"< br >"
else Response.Write " 优秀!"
‘将成绩登记入库
strSql=”insert into user (result) values (”&score&”)
where user=’”&name&”’”
conn.execute(strSql)
% >
< /BODY >
< /HTML >