<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*"%>
<%@ page import="java.lang.Math.*" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>
<%@ include file="/public/checkvalidadmin.jsp"%>
<%@ include file="/public/checkvalidadmin8.jsp"%>
<%!
String id = "";
String sql = "";
ResultSet rs = null;

String currclassid = "";
%>
<html>

<head>
<title>题目信息修改</title>
    <link rel="stylesheet" href="../public/style.css">
	<script language="javascript">
	// 函数mycheck()的作用是验证用户修改题库信息的正确性
	function mycheck() {
		var tmp_selectid = document.myform.selectid.selectedIndex;
		var tmp_answer   = document.myform.answer.value;
        var tmp_choice1  = document.myform.choice1.value;
        var tmp_choice2  = document.myform.choice2.value;
        var tmp_choice3  = document.myform.choice3.value;
        var tmp_choice4  = document.myform.choice4.value;

        if(document.myform.qname.value == "") {
		    alert("请输入题目！");
			return;
		}
        if(tmp_choice1.length==0 || tmp_choice2.length==0 || tmp_choice3.length==0 || tmp_choice4.length==0 ) {
		    alert("请输入各个选项！");
			return;
		}
        if(tmp_answer.length == 0) {
		    alert("请选择题目答案！");
			return;
		}
		if(tmp_selectid==0 && tmp_answer.length>1) {
		    alert("单选题的答案应该唯一！");
			return;
		}
        if(tmp_answer.length > 4) {
		    alert("多选题最多4个答案！");
			return;
		}
		document.myform.submit();
	}
	</script>
</head>
<%
sql = "select * from test_classinfo";
try {
   rs = conn.executeQuery( sql );
}catch(Exception e) {
   out.println("访问课程信息数据出错！");
   return;
}
if(!rs.next()) {
   out.println("系统数据库中无课程信息数据！");
   return;
}


%>
<center>
<form name="myform" action="questionsavenew.jsp" method="post">
	<table width="90%" HEIGHT=100% border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
	  <tr bgcolor="#FAD185"> 
		<td colspan=6 height=20 align=center><b>新增试题</b></td>
	  </tr>
      
	  <tr> 
		<td colspan=6 valign=top>
		<textarea name="qname" rows=20 cols=150></textarea></td>
	  </tr>
      <tr>
		  <td width=10%>选项A</td>
		  <td colspan=5><textarea name="choice1" rows=2 cols=135></textarea></td>
	  </tr>
      <tr>
		  <td>选项B</td>
		  <td colspan=5><textarea name="choice2" rows=2 cols=135></textarea></td>
	  </tr>
      <tr>
		  <td>选项C</td>
		  <td colspan=5><textarea name="choice3" rows=2 cols=135></textarea></td>
	  </tr>
      <tr>
		  <td>选项D</td>
		  <td colspan=5><textarea name="choice4" rows=2 cols=135></textarea></td>
	  </tr>
      <tr>
		  <td>题目类别</td>
		  <td>
		  <select name="selectid">
	        <option value=1 selected>单选题</option>
	        <option value=2>多选题</option>
          </selectid>
		  </td>
		  <td>对应班级</td>
		  <td>
		  <select name="classid">
		  <%
			 do{
				 out.println("<option value=" + rs.getString("classid") + ">");
				 out.println(rs.getString("classname"));
				 out.println("</option>");
			 }while(rs.next());
		  %>
          </select>
		  </td>
		  <td>答案</td>
		  <td><input type=text title="输入答案时请按照字母次序进行输入,例如：AB / ABD" name=answer value=""></td>
	  </tr>
      <tr>
		  <td align=center colspan=6>
		      <input type="button" value="确认增加" onclick="mycheck()">&nbsp;&nbsp;&nbsp;
	          <input type="button" value="返回上一页面" onclick=javascript:history.back()>
		  </td>
	  </tr>
	</table>
</form>
</center>
</html>