首页 > 互联资讯 > 技术交流  > 

如何实现网上考试?

login.asp

' 考生验证.
<
@ Language=VBScript>
<

name=trim(request("name"))
passwd=trim(request("passwd"))
if name<>"" and passwd<>"" then

' 检查考生是否输入用户名和密码.
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver(
.mdb)};

dbq=" Server.MapPat("exercise.mdb")
set rs= server.createobject("adodb.recordset")
sql= "select
from user where user=
'"
name"' and passwd='" passwd "'"
Set rs= conn.Execute(sql)

' 验证考生合法性.
if not(rs.eof) then
if rs("score")<>0 then

' 检查考生是否已参加过考试,若是则进行成绩查询.
response.write rs("user")
"的考试成绩是"rs("score")
else
session("pass")=1
session("user")=name
response.redirect "test.asp"
end if
else
Response.Write "
,您输入的用户名或密码不正确!"
end if
else
end if
>



</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 9.0pt; mso-ascii-font-family: ' '; mso-hansi-font-family: ' '">撼雪喷云之考生登录</SPAN><SPAN lang=EN-US style="FONT-FAMILY: ' '; mso-bidi-font-size: 9.0pt">


FORM1 method=post name=FORM1>

nbsp;


nbsp;


考生:


密码:


进入 " style="FONTSIZE: medium; FONTSTYLE: normal; FONTVARIANT:normal; FONTWEIGHT: bold" title="">






test.asp

' 从题库中取题考试.
<
@ Language=VBScript >
<

if session("pass")<>1 then
response.redirect "login.asp"
else
end if
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (
.mdb)};
dbq="
Server.MapPath("exercise.mdb")
sql="select
from test"
Set rs = conn.Execute( sql )

' 提取试题.
>

' 以上是一个计时函数.







' 调用计时函数显示时间.












' 显示试题.

nbsp;



<
i=1
rs.movefirst
do while not rs.eof
>

nbsp;nbsp; <=rs("question")>


TimeHourMinSec








cellSpacing=1 width="80">







" width="50">
=i> type=radio value="A"><=rs("a")>
=i
type=radio value="B"><
=rs("b")>
=i>
type=radio value="C"><
=rs("c")>
=i>
type=radio value="D"><
=rs("d")>

<

i=i
1
rs.movenext
loop
>



交卷>



result.asp

' 评分并将成绩记录到数据库.
<
@ Language=VBScript >





nbsp;


<
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 "
您的答案:"
score=int(ycorrect/rscount
100)
for i=1 to Request.Form.Count
1
Response.Write Request.Form(i)
next
Response.Write "
"
Response.Write "
您的成绩:"score
if score<60 then Response.Write "
别难过,您不及格!""
"
else if score>=60 Response.Write "
幸好,您及格了!""
"
else Response.Write "
恭喜,您获得了优秀!"


strSql="insert into user (result) values ("
score")
where user='"
name"'"
conn.execute(strSql)

' 将成绩存到数据库.
>

[1]

如何实现网上考试?由讯客互联技术交流栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“如何实现网上考试?