ASP在线试题库与答题系统方案

  • 格式:doc
  • 大小:116.50 KB
  • 文档页数:25

. . .

.

.下载可编辑.

利用ASP和Access数据库制作局域网网上答题系统

信息社会对人的学历、素质要求越来越高,人们为了找到前途更好、收入更加诱人的工作岗位,必须通过各种各样的考试如注册会计师资格考试、司法资格考试等等,而各种各样的试题资料也应运而生,但所有的资料所共有的一个缺点就是使用上的不方便、不灵活、及效率不高,本网上答题系统正是为了弥补这些诸多不便而编制的、适合于局域网并能在单机上运行的系统,下面就详细介绍本系统的编制及使用方法。

一、界面

如图所示: .

. . .

.下载可编辑.

二、程序组成

本系统由Index. asp、Lkzk.asp、Save.asp、Db0.fun 四个小程序及Access数据库文件lkzk.mdb组成各程序的功能分别是:

1. Index. asp 是框架网页,负责导入Lkzk.asp、Save.asp两个子网页组成完整的程序页面。

2. Lkzk.asp 是随机出题答题的交互页面生成程序,主要完成随机选题、题目显示、答案输入及正确率、总答题数显示等功能。

3. Save.asp 完成答题正误判断、显示及成绩登记(按客户端IP地址)。

4. Db0.fun 包含打开Access数据库的多个函数(Lkzk.asp、Save.asp都用到的)。

5. lkzk.mdb Access数据库文件,由表“IP”和表“题库”组成。

表(IP)由编号字段ID(数字格式)、客户机地址字段IP(文本格式)、错误答案数字段nnn(数字格式)、正确答案数字段yyy(数字格式) 所组成;

表“题库” 由题号字段ID(数字格式)、单选多选标记字段dx(数字格式)、答案字段xz(文本格式)、试题容字段na(备注格式)所组成。(注:试题容的选择部分必须为“A. …… B. …… C. …… D. ……” 格式)

--------------- Index. Asp-----------------

网上司考试题库 . . .

.

.下载可编辑.

此网页使用了框架,但您的浏览器不支持框架。

--------------Lkzk.asp-------------

<%

Set rsu2 = GetMdbStaticRecordset("lkzk.mdb", "IP")

Set rs = GetMdbStaticRecordset("lkzk.mdb", "题库")

%>

网上司考试题库

司考试题库

<%

ClientIP = Request.ServerVariables("REMOTE_ADDR")

userIP=Right(ClientIP,Len(ClientIP)-InStrRev(ClientIP,"."))

rsu2.AbsolutePosition=userIP

Randomize

I=Fix(Rnd*1800)

rs.AbsolutePosition=I 1

%>

总第<%=CStr(I 6)%>题 <%'=rs("type")%>

<% s=rs("na")

x=InStr(s,"A.") . . .

.

.下载可编辑. sx="多选"

if rs("dx")=0 then

sx="单选"

end if %>

<%=Left(s,x-1)%> '显示除选择部分外的试题容

<%=sx%> '显示是单选还是多选题

<% s=Right(s,Len(s)-x 1)

x=InStr(s,"B.") %> '以下开始显示复选框及选择部分

<%=Left(s,x-1)%>

<%s=Right(s,Len(s)-x 1)

x=InStr(s,"C.")%>

<%=Left(s,x-1)%>

<%s=Right(s,Len(s)-x 1)

x=InStr(s,"D.")%>

<%=Left(s,x-1)%>

<%s=Right(s,Len(s)-x 1)%>

<%=s%>

继续做题

<%if rsu2("nnn") rsu2("yyy")=0 then rsu2("yyy")=1 end if%>

正确率:<%=FormatNumber(rsu2("yyy")/(rsu2("nnn") rsu2("yyy"))*100, 2,

True)%>%

总答题数:<%=rsu2("nnn") rsu2("yyy")%>

-----------------Save.asp-------------------

<%

Set rsu2 = GetMdbStaticRecordset("lkzk.mdb", "IP")

Set rs = GetMdbStaticRecordset("lkzk.mdb", "题库") . . .

.

.下载可编辑. %>

<% I=CInt(Request("AI"))

rs.AbsolutePosition=I 1

ssx="错"

A=Replace( Request("A"), ", ", "" )

if A=rs("xz") then '判断答题正误

ssx="对"

end if

%>

您答<%=ssx%>了 '显示答案正误等信息

试题库总第<%=CStr(I 1 5)%>题 您的答案是:<%=A%>

参考答案是:<%=rs("xz")%>

<%

ClientIP = Request.ServerVariables("REMOTE_ADDR")

userIP=Right(ClientIP,Len(ClientIP)-InStrRev(ClientIP,"."))

rsu2.AbsolutePosition=userIP

rsu2.Update

If ssx="对" then

rsu2("yyy") =rsu2("yyy") 1

End if

if ssx<>"对" then

rsu2("nnn") =rsu2("nnn") 1

End if

rsu2.Update '以下将正误结果记录于数据库表“IP”中

%>

--------------Db0.fun----------------

<% ' 以下为函数程序

'---------------------------------------------------

Function GetMdbConnection( FileName )

Dim Provider, DBPath

Provider = "Provider=Microsoft.Jet.OLEDB.4.0;" . . .

.

.下载可编辑. DBPath = "Data Source=" & Server.MapPath(FileName)

Set GetMdbConnection = GetConnection( Provider & DBPath )

End Function

'---------------------------------------------------

Function GetMdbRecordset( FileName, Source )

Set GetMdbRecordset = GetMdbRs( FileName, Source, 2, "" )

End Function

'---------------------------------------------------

Function GetMdbStaticRecordset( FileName, Source )

Set GetMdbStaticRecordset = GetMdbRs( FileName, Source, 3, "" )

End Function

'---------------------------------------------------

Function GetConnection( Param )

Dim conn

On Error Resume Next

Set GetConnection = Nothing

Set conn = Server.CreateObject("ADODB.Connection")

If Err.Number <> 0 Then Exit Function

conn.Open Param

If Err.Number <> 0 Then Exit Function

Set GetConnection = conn

End Function

'---------------------------------------------------

Function GetMdbRs( FileName, Source, Cursor, Password )

Dim conn, rs

On Error Resume Next

Set GetMdbRs = Nothing

If Len(Password) = 0 Then

Set conn = GetMdbConnection( FileName )

Else

Set conn = GetSecuredMdbConnection( FileName, Password )

End If

If conn Is Nothing Then Exit Function

Set rs = Server.CreateObject("ADODB.Recordset")

If Err.Number <> 0 Then Exit Function

rs.Open source, conn, Cursor, 2

If Err.Number <> 0 Then Exit Function