<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkuser.asp"-->
<SCRIPT language=vbScript>
Function tgotourl(urlst)
newoj=window.open(urlst,"网上考试系统","width=600,height=500,top=50,left=50,scrollbars=yes,resizable=yes")
end Function
</SCRIPT>
<%
if Request.Form("submit")="下一步" then  '如果选择了考试科目，则进入考试界面
   if Request.Form("selectsubject")="" then
       response.write " <center>你没有选择考试科目，请选择考试科目！</center>"
   else
   dim rs2,sql2
  set rs2=server.createobject("adodb.recordset")
  sql2= "select count(*) from score where studentname='"&session("studentname")&"' and subjectname='"&request.form("selectsubject")&"'"
  rs2.open sql2,conn,1,1
  if rs2(0)=0 then
      session("selectsubjectname")=Request.Form("selectsubject")
      dim rs,sql          
		set rs = server.createobject("adodb.recordset")
	            sql="select * from subject where subjectname='"&session("selectsubjectname")&"'"
                    rs.open sql,conn,1,1	
	'保存单选试题数量
	session("singlenumber")=rs("singlenumber")
	'保存多选试题数量
	session("multinumber")=rs("multinumber")
	'保存单选试题分值
	session("singleper")=rs("singleper")
	'保存多选试题分值
	session("multiper")=rs("multiper")
	'保存考试时间
	session("testtime")=rs("testtime")	
	'保存考试科目名称
	session("selectsubjectname")=request.form("selectsubject")
        session("yikao")=0
        session("yijiao")=0
	 
	'进入考试界面
	rs.close
        set rs=nothing
%>
<SCRIPT language=vbScript>
tgotourl("test.asp")
</SCRIPT>
<%
	else
	response.write "<center>对不起，您已经参加了<font color=red>"&request.form("selectsubject")&"</font>科目的考试，不能再考。</center>"
	end if
  end if  
end if
%>
<html>
<head>
<title>考试科目选择</title>
</head>
<body background=images/backimage.gif>
<p align=center><font face ="华文行楷" size="5" color=blue>亲爱的</font><FONT size=4 color=red face=隶书> 
  <%Response.Write session("studentname")%>
  </FONT> <font face ="华文行楷" size="5" color=blue>用户，欢迎您进入网上考试系统 V 1.0，请您遵守考场规则，注意把握时间</font> 
</p>
<div align="left">
  <table width="70%" border="0" align="center">
    <tr>
      <td><font color="#FF0000" size="4">考试规则：</font><br>
        1、时间到，系统将自动交卷。<br>
        2、请不要按<b><font color="#FF0000">F5</font></b>按钮进行刷新或按<b><font color="#FF0000">后退</font></b>按钮后退，否则你的成绩将被记为0分。</td>
    </tr>
  </table>
</div>
<br>
<table width="70%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor=blue>
  <tr> 
    <td width="25%"> 
      <div align="center">学生姓名</div>
    </td>
    <td width="25%"> 
      <div align="center">考试科目</div>
    </td>
    <td width="25%"> 
      <div align="center">考试时间</div>
    </td>
    <td width="25%"> 
      <div align="center">考试分数</div>
    </td>
  </tr>
  <%
  dim rs1,sql1
  set rs1=server.createobject("adodb.recordset")
  sql1= "select * from score where studentname='"&session("studentname")&"' order by score desc"
  rs1.open sql1,conn,1,1
  if err.number <> 0 then
	           response.write "数据库出错"
           else
	           if rs1.bof and rs1.eof then
		           rs1.close
		           response.write "目前没有您的考试纪录"
	           else
			       response.write "您已参加考试的科目及分数如下："
			       do while not rs1.eof %>
  <tr> 
    <td width="25%" height="21" > 
      <div align="center"><%=rs1("studentname")%></div>
    </td>
    <td width="25%" height="21" > 
      <div align="center"><%=rs1("subjectname")%></div>
    </td>
    <td width="25%" height="21" > 
      <div align="center"><%=rs1("endtime")%></div>
    </td>
    <td width="25%" height="21" > 
      <div align="center"><%=rs1("score")%></div>
    </td>
  </tr>
  <% rs1.movenext				   
	loop			   
	end if	       
       end if 
%>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="500" height="156">
<tr>
<td width=30%>
</td>
<td width=70%>
<form action="selectsubject.asp" method="post" id="form" name="form">
<p align=left><FONT color=green face=宋体 size=4>请您选择考试科目：</FONT> 
<br><br>
<%
   	
		set rs = server.createobject("adodb.recordset")
	            sql="select * from subject"
                    rs.open sql,conn,1,1
               if err.number<>0 then 
		response.write "数据库操作失败："&err.description
               elseif rs.bof and rs.eof then
		        response.write "<center>对不起,暂时没有任何考试科目。</center>"
			    rs.close		    
	       else                          
	             do while not rs.eof
	              Response.Write( "<input name=selectsubject type=radio value=" & rs("subjectname") & ">" & rs("subjectname") & "，考试时间为" & rs("testtime") & "分钟<br>")
	              rs.movenext         
	             loop   
	       end if
	       rs.close
          set rs=nothing
      call endConnection()
%>
</p>
        <p align=left > 
          <input  name="submit" type="submit" value="下一步">
        </p>
</form>
</td>
</tr>
</table>
<p align="center"><a href="lgout.asp">退出考试</a></p>
</body>
</html>