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

ASP
ASP汉字转拼音,支持自定义特殊词语
终于找到了ASP下标越界的解决方法
ASP实现长文章手动分页的代码
如何节约程序开发中的时间
防sql注入代码
asp连接远程mssql数据库代码
fso检测文件、磁盘、文件夹是否存在代码
asp随机获取数据库中的记录代码
利用fso显示某一文件夹中的所有内容
利用asp获取客户端真实的IP地址
Cookies常用命令简介
将多行区域表单中的内容换成html代码
rs.open sql,conn,1,1中各参数的意义
动态图形验证码
常用的asp代码
ASP如何得到字符串的每一位字符
ASP用户登录代码
网站静态页面生成方法
fso生成有多行内容的html文件
fso向html文件追加内容

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 61 ::
收藏到网摘: 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)
结果是用一个简单的表格格式来显示的。

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