信息社会对人的学历、素质要求越来越高,人们为了找到前途更好、收入更加诱人的工作岗位,必须通过各种各样的考试如注册会计师资格考试、司法资格考试等等,而各种各样的试题资料也应运而生,但所有的资料所共有的一个缺点就是使用上的不方便、不灵活、及效率不高,本网上答题系统正是为了弥补这些诸多不便而编制的、适合于局域网并能在单机上运行的系统,下面就详细介绍本系统的编制及使用方法。
一、界面
如图所示:
二、程序组成
本系统由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-----------------
<html>
<head>
<title>网上司考试题库</title>
</head>
<frameset rows="87%,*" framespacing="0">
<frame name="top" src="lkzk.asp" scrolling="auto">
<frame name="bottom" scrolling="auto" marginwidth="0" marginheight="0">
<noframes>
<body>
<p>此网页使用了框架,但您的浏览器不支持框架。</p>
</body>
</noframes>
</frameset>
</html>
--------------lkzk.asp-------------
<!-- #include virtual="/lkzk/db0.fun" -->
<%
set rsu2 = getmdbstaticrecordset("lkzk.mdb", "ip")
set rs = getmdbstaticrecordset("lkzk.mdb", "题库")
%>
<html>
<head>
<title>网上司考试题库</title>
</head>
<body >
<font size="4" color="#000080">司考试题库
<%
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")%>
<form action=save.asp method=get target="bottom">
<input type=hidden name=ai value="<%=i%>">
<hr>
<% s=rs("na")
x=instr(s,"a.")
sx="多选"
if rs("dx")=0 then
sx="单选"
end if %>
<%=left(s,x-1)%> '显示除选择部分外的试题内容
<font color="red">
<%=sx%> <br> '显示是单选还是多选题
</font>
<% s=right(s,len(s)-x+1)
x=instr(s,"b.") %> '以下开始显示复选框及选择部分
<input type=checkbox name=a value="a">
<%=left(s,x-1)%><br>
<%s=right(s,len(s)-x+1)
x=instr(s,"c.")%>
<input type=checkbox name=a value="b">
<%=left(s,x-1)%><br>
<%s=right(s,len(s)-x+1)
x=instr(s,"d.")%>
<input type=checkbox name=a value="c">
<%=left(s,x-1)%><br>
<%s=right(s,len(s)-x+1)%>
<input type=checkbox name=a value="d"> <%=s%>
<br>
<input type=submit value="查看答案">
<a href="lkzk.asp" target="_self">继续做题</a> <br>
<%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")%>
</form>
</font>
</body>
-----------------save.asp-------------------
<!-- #include virtual="/lkzk/db0.fun" -->
<%
set rsu2 = getmdbstaticrecordset("lkzk.mdb", "ip")
set rs = getmdbstaticrecordset("lkzk.mdb", "题库")
%>
<html>
<body >
<% i=cint(request("ai"))
rs.absoluteposition=i+1
ssx="错"
a=replace( request("a"), ", ", "" )
if a=rs("xz") then '判断答题正误
ssx="对"
end if
%>
<font color=red>
您答<%=ssx%>了 '显示答案正误等信息
</font>
试题库总第<%=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”中
%>
</body>
</html>
--------------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
set getmdbrs = rs
end function
'---------------------------------------------------
%>
三、运行方法
本系统运行方法是先按文中所述格式制作好试题库文件lkzk.mdb连同上列四个程序copy至主机的www 的根目录中并执行http://主机ip地址/index.asp即可进行答题。(本程序在单机windows98+pws+odbc驱动 及局域网windowsnt server4.0 +iis4.0+odbc驱动 环境下均测试通过,各用户可以根据具体情况对程序中的标题稍加修改制作自己的试题库系统,还可以对其进行扩充增加各类其它功能,在这里因篇幅关系就不再敷述,有关odbc驱动的详细情况可参阅相关资料或给我来信mailto: intcom@21cn.com 。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器