<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String driver = "jdbc:microsoft:sqlserver://localhost:1433";
String user="jsp";
String password="820728";
Connection conn = DriverManager.getConnection(driver,"","");
Statement stmt = conn.createStatement();
int xuanzeti=0;
int panduanti=0;
int zhuguanti=0;
int shijuanbianhao=Integer.parseInt(request.getParameter("shijuanbianhao"));
%>
<div align="center"><h1>模拟试卷<%=shijuanbianhao%></h1></div>

<%
ResultSet rs=stmt.executeQuery("SELECT * FROM shijuan where shijuanbianhao="+shijuanbianhao);
ResultSet rs1;
int kaoshishijian;
int i=0;
int j=0;
int k=0;
int xuanzefenzhi=0;
int panduanfenzhi=0;
int zhuguanfenzhi=0;
%>
<form name="allmyans" action="kaoshi1.jsp" method="post">
<input type="hidden" name="shijuanbianhao" value="<%=shijuanbianhao%>">
<%
while(rs.next())
{
    i++;
    int fenzhi=Integer.parseInt(rs.getString("fenzhi"));
	String timuleixing=rs.getString("timuleixing");	
	int id=Integer.parseInt(rs.getString("id"));
	kaoshishijian=Integer.parseInt(rs.getString("kaoshishijian"));
    stmt=conn.createStatement();
	rs1=stmt.executeQuery("select * from "+timuleixing+" where id="+id);
	rs1.next();
	if(timuleixing.charAt(0)=='x')
	{
	xuanzefenzhi=fenzhi;
	if(xuanzeti==0)
	{%>
	<h4>考试时间为<%=kaoshishijian%>分钟</h4>
	<h3>一、选择题：(以下单选题每题<%=xuanzefenzhi%>分)</h3>
	<%
	xuanzeti=1;
	}
	String answer;
	String answer1;
	String answer2;
	String answer3;
	String answer4;
%>
<p><%=i%>、<%String Qus=rs1.getString("tigan");%><%=Qus%></p>
<%	 answer=rs1.getString("daan");
     answer1=rs1.getString("a");
	 answer2=rs1.getString("b");
	 answer3=rs1.getString("c");
	 answer4=rs1.getString("d");
     session.setAttribute("Qus"+i,Qus);
	 session.setAttribute("Ans"+i,answer);
	 session.setAttribute("Ansa"+i,answer1);
	 session.setAttribute("Ansb"+i,answer2);
	 session.setAttribute("Ansc"+i,answer3);
	 session.setAttribute("Ansd"+i,answer4);
	 %>
<table>
<input type="hidden" name="timuleixing<%=i%>" value="<%=timuleixing%>">
<input type="hidden" name="fenzhi<%=i%>" value="<%=xuanzefenzhi%>">
<tr>
   <td><input name="myans<%=i%>" type="radio" value="a" />A.<%=answer1%></td>
   <td><input name="myans<%=i%>" type="radio" value="b" />B.<%=answer2%></td>
   <td><input name="myans<%=i%>" type="radio" value="c" />C.<%=answer3%></td>
   <td><input name="myans<%=i%>" type="radio" value="d" />D.<%=answer4%></td>
</tr>
</table>
	 <%
	 continue;
    }
	if(timuleixing.charAt(0)=='p')
	{
	panduanfenzhi=fenzhi;
	String answer;
	if(panduanti==0)
	{%>
	<h3>二、判断题：（每题<%=panduanfenzhi%>分）</h3>
	<%
	panduanti=1;
	}
	%>
	<P><%=i%>、<%String Qus=rs1.getString("tigan");%><%=Qus%></P>
	<%
	 answer=rs1.getString("daan");
     session.setAttribute("Qus"+i,Qus);
	 session.setAttribute("Ans"+i,answer);
	 %>
	 <table>
	 <input type="hidden" name="timuleixing<%=i%>" value="<%=timuleixing%>">
<input type="hidden" name="fenzhi<%=i%>" value="<%=panduanfenzhi%>">
<tr>
   <td><input name="myans<%=i%>" type="radio" value="t" />T.</td>
   <td><input name="myans<%=i%>" type="radio" value="f" />F.</td>
</tr>
</table>
	 <%
	 continue;
	}
	if(timuleixing.charAt(0)=='z')
	{
	 zhuguanfenzhi=fenzhi;
	 String answer;
	 if(zhuguanti==0)
	 {%>
	 <h3>三、主观题：(每题<%=zhuguanfenzhi%>分)</h3>
	 <%
	 zhuguanti=1;
	 }
	 %>
	<table>
	 <tr>
   <td><%=i%>、<%String Qus=rs1.getString("tigan");%><%=Qus%>
   <%//session.setAttribute("i",i);
     answer=rs1.getString("daan");
     session.setAttribute("Qus"+i,Qus);
	session.setAttribute("Ans"+i,answer);
	%></td>
</tr>
</table>
<table>
<tr><input type="hidden" name="timuleixing<%=i%>" value="<%=timuleixing%>">
<input type="hidden" name="fenzhi<%=i%>" value="<%=zhuguanfenzhi%>">
   <td>答案是：<textarea rows="10" cols="70" name="myans<%=i%>"></textarea></td>
</tr>
</table>
	 <%
	}
}
%>
<input type="hidden" name="timuzongshu" value="<%=i%>">
<input name="submit1" type="submit" class="button1" value="提交(考虑清楚哦)" />
        <input name="submit2" type="reset" class="button1" value="清除(也要考虑清楚哦)" />
</form>
</body>
</html>
