<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
'在提交答卷后,首先要对答卷内容进行统计,答对多少题目
'应该得多少分,然后将统计结果写入到表score(stid,score,teachid,sub)中,
'然后将记录学生回答的表tbanswer中的相应字段删除
dim rightnum '该变量记录答对的题目的数量
dim totalques '该变量记录的是做的总的题目的数量
dim getscore '学生应得得分数
set mcmd=server.CreateObject("adodb.command")
mcmd.ActiveConnection="dsn=testsys"
mcmd.CommandText="right"
'command对象的commandtext属性为存储查询过程right,在access数据库中设计了带
'参数studentid的查询right
set mprama=mcmd.CreateParameter("studentid",200,1,8,session("stid"))
'创建参数studentid,向查询存储过程传递该参数
mcmd.Parameters.Append mprama
set mrs=mcmd.Execute
if not mrs.eof then
rightnum=mrs("rightnum")
end if
mcmd.Parameters.Delete "studentid"
set mprama=nothing
mcmd.CommandText="DELETE * FROM tbanswer WHERE stid='" & session("stid") & "'"
mcmd.Execute
'删除存储在数据库表tbanswer的记录答题的记录
set mrs=nothing
getscore=rightnum*100/session("testnum")
'以下为将分数写入到表score中
mcmd.CommandText="insert into score (stid,score,sub,teachid) values('" & session("stid") & "','" & getscore & "','" & session("subname") & "','" & session("teachid") & "')"
mcmd.Execute
set mcmd=nothing
session.Abandon
%>
<P align=center><STRONG><FONT color=crimson face=""
size=4>评分统计</FONT></STRONG></P>
<P align=center>
<TABLE border=1 cellPadding=1 cellSpacing=1 width=75%>
<TR>
<TD>学生姓名</TD>
<TD><%=session("stname")%></TD></TR>
<TR>
<TD>考试科目</TD>
<TD><%=session("subname")%></TD></TR>
<TR>
<TD>题目总数
<TD><%=session("testnum")%>
<TR>
<TD>做对题数
<TD><%=rightnum%>
<TR>
<TD>得分
<TD><%=getscore%>
<TR>
<TD></TD>
<TD></TD></TR></TABLE></P>
</BODY>
</HTML>