www.gusucode.com > ASP毕业设计在线考试管理系统源码 > ASP毕业设计在线考试管理系统源码\code\user\result.asp

    <link href="../Style.css" rel="stylesheet" type="text/css">
<!--#include file="db.asp"-->
<%
subject=request("subject")
testid=request("testid")
singlecount=request("singlecount")
singleper=request("singleper")
multicount=request("multicount")
multiper=request("multiper")
judgecount=request("judgecount")
judgeper=request("judgeper")
userid=request.cookies("userid")
starttime=request("mystarttime")
endtime=time()
score=0
j=0
for each element in request.form
  for i=1 to request.form(element).count
    if instr(element,"NO")<>0 then
      id=mid(element,3,3)
      result=request.form(element)(i)
      sql="select * from question where id="& clng(id)
      set rs=server.createobject("adodb.recordset")
      rs.open sql,conn,3,2
      if rs("type")="单选题" then
        if result=rs("answer") then
          score=score+cint(singleper)
        end if
      end if
      if rs("type")="多选题" then
        if instr(rs("answer"),result)<>0 then
          score=score+cint(multiper)/4
          j=j+1
          answer=split(rs("answer"),",")
          answercount=ubound(answer)+1
          if answercount=j then
            score=score+cint(multiper)*(1-j/4)
          end if
        else
          score=score-cint(multiper)/4*(j)
        end if
      end if
      if rs("type")="判断题" then
        if rs("answer")=result then
          score=score+cint(judgeper)
        end if
      end if      
    end if
  next
next

sql="select * from score"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs.addnew
rs("userid")=userid
rs("username")=request.cookies("username")
rs("subject")=subject
rs("testid")=testid
rs("starttime")=starttime
rs("endtime")=endtime
rs("score")=score
rs.update
rs.close
sql="select * from test_record where testid="& testid & " and userid=" & userid
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs("tested")=1
rs.update
rs.close
response.redirect "displayresult.asp?userid=" & userid & "&testid=" & testid
%>