当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP开发一个在线考试程序(七)

ASP
asp中缓存cache技术的应用
escape解决AJAX中文乱码的简单方法
提高asp程序访问速度的方法
17个ASP编程基础典型代码
用asp编写类似搜索引擎功能的代码
ASP-server.URLEncode反函数:urldecode
判断远程图片是否存在的asp技巧
ASP采集-ASP采集程序原理
好用的asp防SQL注入代码
asp中提取HTML中图片的SRC路径
FileSystemObject 示例代码
asp动态页面生成html页面
ASP中的常用服务器检测源码
asp无组件上传并插入到数据库里
ASP+AJAX做类似google的搜索提示
asp的RegExp对象正则表达式功能用法
ASP怎样获得代码中第一张图片地址
ASP实现多域名同一空间的处理实例
ASP无组件上载,带进度条,多文件上载
用GetString来提高ASP的速度

用ASP开发一个在线考试程序(七)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 65 ::
收藏到网摘: n/a

  Result.asp
  这一页的主要目的是显示结果,同时将这些结果插入数据库以备将来参考。
for each item in Request.Form
sql_check = "select Count(*) from "&subject&" where answer ='" & Request.Form(item) & "'"
Set RS_check = Application("Conn").Execute(sql_check)
if RS_check(0) > 0 then
result = result + 1
end if
next
  变量result中存储了结果。
  百分数是从result中算出来的,如下所示:
percent = round(( 100 * result )/count)
  要将这个结果存储在数据库中,执行以下查询:
sql_id = "select id from loginuser where username='" & Session("username") &"'"
Set RS_id = Application("Conn").Execute(sql_id)
id= RS_id(0)
SQL_insert = "insert into details (ref_id,subject,score) values('" & id & "','" _
& subject & "', '" & percent &"') "
Set RS_insert = Application("Conn").Execute(SQL_insert)
View.asp
  观看模块检查会员是否以前曾经进行过在线考试。如果是的话,将用户引导到viewrecord.asp。如果没有的话,显示
相应的信息。
sql_id= "select id from loginuser where username='" & Session("username") &"'"
Set RS_id = Application("Conn").Execute(sql_id)
id= RS_id(0)
sql_count = "Select count(*) from details where ref_id = '" & id &"'"
Set RS_count = Application("Conn").Execute(sql_count)
If RS_count(0) < > 0 Then
response.redirect "viewrecord.asp"
End If
If RS_count(0) = 0 Then
Session("noview") = "NO ONLINE EXAMINATIONS HAVE BEEN GIVEN"
response.redirect "default.asp"
End If
Viewrecord.asp
  Viewrecord.asp页使会员能够观看一些他们的细节信息。查询如下:
sql_details = "Select *subject, score from details where ref_id = '" & id &"'"
Set RS_details = Application("Conn").Execute(sql_details)
结果是用一个简单的表格格式来显示的。

  请注意,我并没有将会员可以进行一个主题的考试次数限制为一次。同一个主题考试可以进行任意次。