<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkuser.asp"-->
<html>
<head>
<title>考试界面</title>
</head>
<body bgcolor="#FFFFFF" background=images/backimage.gif>
<p align="center"><b><font face="宋体" size="5" color="#FF0000"><%=session("selectsubjectname")%>考试</font></b></p>
<br>
<%
if request.form("submit1")="开始考试"  then
    dim yikao,testtime,hours,minutes
    yikao=session("yikao")
    if yikao=1 then
       response.write "您是否按了浏览器上的后退或刷新按钮，你已经考试过了，请不要再按了。"
    else
    session("yikao")=1
	testtime=session("testtime")
	hours=clng(testtime)\60
	minutes=clng(testtime) mod 60
    '保存开始时间
    dim starttime,i,sql,rs,count,temp,strid1,strid2
    session("starttime")=hour(now())*60+minute(now())
    starttime=session("starttime")
    sql="select * from score"
    set rs=server.createobject("adodb.recordset")
    rs.open sql,conn,3,2
    rs.addnew
    rs("studentname")=session("studentname")
    rs("subjectname")=session("selectsubjectname")
    rs("endtime")=now()
    rs("score")=0
    rs.update
    rs.close
%>
<form name=forms>
<center>                      
<div align=center><span class="unnamed1">考试时间：<%=hours%>小时<%=minutes%>分 您已经做了：
<input type=text name=input1 size=9>
<script language=javascript>
<!--
var sec=0;var min=0;var hou=0;flag=0;idt=window.setTimeout("update();",1000);
function update()
{sec++;
if(sec==60)
{sec=0;min+=1;}
if(min==60)
{min=0;hou+=1;}
if((min>0)&&(flag==0))
{flag=1;}
document.forms.input1.value=hou+"时"+min+"分"+sec+"秒";
if(document.forms.input1.value==<%=hours%>+"时"+<%=minutes%>+"分0秒")
{alert("时间到了，请交卷！");document.testform.submit.click();}
idt=window.setTimeout("update();",1000);
}
//-->
</script>
</span></div>
</center>
</form>
<form method="POST" action="getresult.asp"  name="testform">
  <table border="0" cellspacing="0"  bordercolor="#111111" width="100%" >
    <tr>
      <td width="100%" height="25"><b><font size="3" color="#000080">一、单项选择题(每题<%=session("singleper")%>分,共<%=session("singlenumber")%>题)</font></b></td>
    </tr>
  </table>
  <%
strid1=""
strid2=""
randomize
for i=1 to session("singlenumber")
set rs=server.createobject("adodb.recordset")
sql="select * from question where subjectname='"&session("selectsubjectname") & "'and type='单选题' and haveselect=0 "
rs.open sql,conn,3,2
count=rs.recordcount
temp=fix(count*rnd(10))
rs.move temp
rs("haveselect")=1

strid1=strid1 & rs("ID") & ","

%>
  <table border="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="100%"  cellpadding="0">
    <tr>
      <td width="100%" bgcolor="#EFEFEF" height="20">&nbsp;&nbsp;<b><%=i%>、<%=rs("question")%></b></td>
    </tr>
    <%
  if rs("A")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NO<%=rs("id")%>" value="A">A、<%=rs("A")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("B")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NO<%=rs("id")%>" value="B">B、<%=rs("B")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("C")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NO<%=rs("id")%>" value="C">C、<%=rs("C")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("D")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NO<%=rs("id")%>" value="D">D、<%=rs("D")%></td>
    </tr>
  <%
  end if
  %>   
  </table>
  <%  
  rs.update
next
rs.close
set rs=nothing
%>
  <table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3">
    <tr>
      <td width="100%" height="25"><b><font color="#000080" size="3">二、多项选择题(每题<%=session("multiper")%>分,共<%=session("multinumber")%>题。每题至少有1项正确的答案，少选、多选、错选均不得分)</font></b></td>
    </tr>
  </table>
  <%
randomize
for i=1 to session("multinumber")
set rs=server.createobject("adodb.recordset")
sql="select * from question where subjectname='"&session("selectsubjectname") & "'and type='多选题' and haveselect=0 "
rs.open sql,conn,3,2
count=rs.recordcount
temp=fix(count*rnd(10))
rs.move temp
rs("haveselect")=1

strid2=strid2 & rs("ID") & ","

%>
  <table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
    <tr>
      <td width="100%" bgcolor="#EFEFEF" height="20">&nbsp;&nbsp;<b><%=i%>、<%=rs("question")%></b></td>
    </tr>
    <%
  if rs("A")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="NO<%=rs("id")%>" value="A">A、<%=rs("A")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("B")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="NO<%=rs("id")%>" value="B">B、<%=rs("B")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("C")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="NO<%=rs("id")%>" value="C">C、<%=rs("C")%></td>
    </tr>
    <%
  end if
  %> <%
  if rs("D")<>"" then
  %>
    <tr>
      <td width="100%">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="NO<%=rs("id")%>" value="D">D、<%=rs("D")%></td>
    </tr>
    <%
  end if
  %> 
  </table>
  <% 
  rs.update
next
rs.close

response.write("<input type='hidden' name='hidQuestID1' value=" & strID1 & ">")
response.write("<input type='hidden' name='hidQuestID2' value=" & strID2 & ">")

set rs=nothing
set rs=server.createobject("adodb.recordset")
sql="select * from question where haveselect=1 "
rs.open sql,conn,3,2
rs.movefirst
 do while  not rs.eof  
   rs("haveselect")=0
   rs.update
   rs.movenext
 loop
rs.close
set rs=nothing
call endConnection()
'response.write(strid1)
'response.write(strid2)
%> 
<p align=center><input type="submit" value="交卷" name="submit" ></p>
</form>
<%
end if
%>
 <%
  else 
  %>
  <form method="POST" action="test.asp"  name="form">
<p align=center><input type="submit" value="开始考试" name="submit1" ></p>
</form>
<%
 response.write "<center>请选择开始考试！</center>"
 end if
 %>

</body>
</html>