成都建设银行总行地址:asp高手请进

来源:百度文库 编辑:杭州交通信息网 时间:2021/01/27 09:19:11
下边这一段代码是考试系统多选题计分的计算方法:
少选的四分之一的分数,多选不得分.可是现在有点问题.计分不正确,不知道该如何处理,请各位大虾帮忙!
或者直接改成选错和选对直接不给分也可以!多谢!
代码如下:
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
问题补充:开始的程序:
<!--#include file="conn.inc"-->

<%
'读入试卷信息
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 exam_database 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 exam_score"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs.addnew
rs("userid")=userid
rs("username")=request.cookies("username")
rs("department")=request.cookies("department")
rs("office")=request.cookies("office")
rs("duties")=request.cookies("duties")
rs("subject")=subject
rs("testid")=testid
rs("starttime")=starttime
rs("endtime")=endtime
rs("score")=score
rs.update
rs.close
sql="select * from exam_testuser where testid="& testid & " and userid=" & userid
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2
rs("havetest")=1
rs.update
rs.close
response.redirect "displayresult.asp?userid=" & userid & "&testid=" & testid
%>
说错了,改成少选,多选都不给分也可以.
多谢了!