mn_test_quest_add.jsp
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:10k
源码类别:

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
  2. <%@ page errorPage="QuestGen_error.jsp" %>
  3. <%@ page import="java.io.*"%>
  4. <%@ page import="jinghua.Tools"%>
  5. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  6. </jsp:useBean>
  7. <%!Connection con=null;
  8. String teachID="";
  9. String sql=null;
  10. Statement stmt=null;
  11. ResultSet rs=null;
  12. String testname=null;
  13. %>
  14. <%
  15. try{
  16. String testID=request.getParameter("testID");
  17. String mntestID=request.getParameter("mntestID");
  18. if(testID==null || mntestID==null)
  19. throw new Exception("调用参数不足!");
  20.  con=DBCon.getConnection();
  21. sql="SELECT  `test`.`paper`,`test`.`testnum`,  `test`.`title`,  `test`.`date`,  `test`.`mark`"+
  22. "  FROM  `test` WHERE  (`test`.`id` = "+testID+")";
  23.     stmt=con.createStatement();
  24.     rs=stmt.executeQuery(sql);
  25. if(rs.next()){
  26. testname=rs.getString("title");
  27. rs.close();
  28. stmt.close();
  29. }else{
  30. rs.close();
  31. stmt.close();
  32. throw new Exception("查询试卷题目错误!");
  33. }
  34. %>
  35. <script language="javascript">
  36. function CheckForm(f)
  37. {
  38. //获取HTML文本
  39. if (editor.EditMode.checked==true)
  40.   document.myform.Content.value=editor.Composition.document.body.innerText;
  41.    else
  42.   document.myform.Content.value=editor.Composition.document.body.innerHTML;
  43. //var v=document.myform.Content.value=editor.Composition.document.body.innerHTML;
  44. //alert(v);
  45. if (f.Answer.value.length < 1) // 没有输入答案
  46. {
  47.     alert("您还没有输入答案!");
  48. return false;
  49. }
  50. if( f.Mark.value.length<1)
  51. {
  52.     alert("您还有输入该试题的分数!");
  53. return false;
  54. }
  55. if(!isNumberString(f.Mark.value,"1234567890."))
  56. {
  57.     alert("嘿!您在分数里填了东西,但怎么不是数字呢?n");
  58.     return false;
  59. }
  60.     if( f.Grade.selectedIndex == 0) {
  61.         alert("请选择年级信息!")
  62.         return false;
  63.     }
  64.     if(f.Subject.selectedIndex==0){
  65.         alert("请选择科目信息!")
  66.         return false;
  67.     }
  68.     if((f.KnowPoint1.selectedIndex==0)&&(f.KnowPoint2.selectedIndex==0)&&(f.KnowPoint3.selectedIndex==0)){
  69.         alert("请选知识点信息!")
  70.         return false;
  71.     }
  72. return true;
  73. }
  74. function isNumberString (InString,RefString)
  75. {
  76. if(InString.length==0) return (false);
  77. for (Count=0; Count < InString.length; Count++)  {
  78. TempChar= InString.substring (Count, Count+1);
  79. if (RefString.indexOf (TempChar, 0)==-1)
  80. return (false);
  81. }
  82. return (true);
  83. }
  84. function gotestpaper(){
  85. document.myform.method = "POST";
  86.     document.myform.action = "modify_test_mn_paper.jsp?testID=<%=testID%>&mnID=<%=mntestID%>";
  87.     document.myform.target="_self";
  88.     document.myform.submit();
  89. }
  90. </script>
  91. <!--年级,科目,知识点三个下拉列表框联动-->
  92. <%
  93. String temp=Tools.sub_know(DBCon.getConnection());
  94. out.print(temp);
  95. temp=Tools.grade_sub(DBCon.getConnection());
  96. out.print(temp);
  97. %>
  98. <script language="JavaScript">
  99. function changegs(locationid){
  100.     document.myform.Subject.length =1;
  101.         document.myform.KnowPoint1.length =1;
  102.         document.myform.KnowPoint2.length =1;
  103.         document.myform.KnowPoint3.length =1;
  104.         var locationid=locationid;
  105.         var i;
  106.         for (i=0;i < gscount; i++){
  107.             if (grade_sub[i][0] == locationid) {
  108.             document.myform.Subject.options[document.myform.Subject.length] = new Option(grade_sub[i][2], grade_sub[i][1]);
  109.             }
  110. }
  111. }
  112. </script>
  113. <script language="JavaScript">
  114. function changesk(locationid){
  115. document.myform.KnowPoint1.length =1;
  116.     document.myform.KnowPoint2.length =1;
  117.     document.myform.KnowPoint3.length =1;
  118. var locationid=locationid;
  119. var i;
  120. for (i=0;i < gskcount; i++){
  121. if (grade_sub_know[i][1] == locationid){
  122. document.myform.KnowPoint1.options[document.myform.KnowPoint1.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  123.             document.myform.KnowPoint2.options[document.myform.KnowPoint2.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  124.             document.myform.KnowPoint3.options[document.myform.KnowPoint3.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  125. }
  126. }
  127. }
  128. </script>
  129. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  130. <html>
  131. <head>
  132. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  133. <link rel="stylesheet" type="text/css" href="../css.css">
  134. <title>试题提交</title>
  135. </head>
  136. <body>
  137. <FORM action="mn_test_quest_add_rs.jsp" method=post name=myform target="_self" onSubmit="return CheckForm(this)">
  138.   <TABLE width="100%" border=0 align=center cellPadding=0 cellSpacing=0>
  139.     <TBODY>
  140.       <TR>
  141.         <TD width="21%" rowSpan=2> <div align="left"><img height=45 src="images/logo.gif"
  142.   width=160></div></TD>
  143.         <TD width="63%" height=45>
  144.           <div align="center"><strong><font color="#3366FF" size="+2" face="黑体">试题录入<strong><font color="#3366FF" size="+2" face="黑体">:<%=testname%></font></strong></font></strong></div></TD>
  145.         <TD width="16%"><div align="right"></div></TD>
  146.       </TR>
  147.     </TBODY>
  148.   </TABLE>
  149.    
  150.   <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  151.     <!--DWLayoutTable-->
  152.     <tr>
  153.     <td width="100%" height="535" valign="top">
  154. <table width="100%" height="354" border="1" bordercolor="#d3add1" background="images/lvbgcolor.gif">
  155.           <tr>
  156.             <td width="34%" height="40" align="left" valign="middle"> 题目类型:
  157.               <select id=QuestType name=QuestType>
  158.                 <%Tools.showOption("select * from questtype",con,out);%>
  159.               </select>
  160.             </td>
  161.             <td width="66%" align="left" valign="middle"><table width="100%" border="0">
  162.                 <tr>
  163.                   <td width="21%" height="39" align="left" nowrap>答案: <input name="Answer" type="text" id="Answer3" size="5" maxlength="5">
  164.                   </td>
  165.                   <td width="20%" align="left" nowrap>分数: <input name="Mark" type="text" id="Mark2" size="5"></td>
  166.                   <td width="26%" align="left" nowrap> <div align="left">难易度:
  167.                       <select name=Difficulty id="select6">
  168.                         <option value="A" selected>A</option>
  169.                         <option value="B">B</option>
  170.                         <option value="C">C</option>
  171.                         <option value="D">D</option>
  172.                         <option value="E">E</option>
  173.                       </select>
  174.                     </div></td>
  175.                   <td width="11%" align="left" valign="middle"> <input name="Submit" type="submit" class="s03" value="提交">
  176.                   </td>
  177.                   <td width="11%" align="left" valign="middle">
  178.   <input name="Reset_Quest" type="reset" class="s03" id="Reset_Quest2" value="重置">
  179.                   </td>
  180.                   <td width="11%" align="left" valign="middle">
  181.   <input name="Submit2" type="button" class="s03" onClick="gotestpaper()" value="返回"></td>
  182.                 </tr>
  183.               </table></td>
  184.           </tr>
  185.           <tr>
  186.             <td height="40" align="left" valign="middle"> 年 级:
  187.               <select id=select10 name=Grade onClick="changegs(document.myform.Grade.options[document.myform.Grade.selectedIndex].value)" size="1">
  188.                 <option value="temp">未选择</option>
  189.                 <%Tools.showGradeOption(con,out);%>
  190.               </select> </td>
  191.             <td rowspan="3" align="center"> <iframe src="../editor/edit.jsp" id='editor' frameborder=0 scrolling=auto width=544 height=321>
  192.               </iframe>
  193.               <textarea name="Content" style="display:none"></textarea>
  194.               &nbsp; <input name="group" type="hidden" id="group" value="single">
  195.               <input name="testID" type="hidden" id="testID" value="<%=testID%>">
  196.               <input name="teacherID" type="hidden" value="1">
  197.               <input name="mntestID" type="hidden" id="mntestID" value="<%=mntestID%>"></td>
  198.           </tr>
  199.           <tr>
  200.             <td height="40" align="left" valign="middle"> 科 目:
  201.               <select id=select8 name=Subject onClick="changesk(document.myform.Subject.options[document.myform.Subject.selectedIndex].value)"
  202. size="1">
  203.                 <option value="temp">未选择</option>
  204.                 <%--Tools.showOption("select * from subject order by id",con,out);--%>
  205.               </select>
  206.             </td>
  207.           </tr>
  208.           <tr>
  209.             <td height="215" align="left" valign="top">
  210.               <table width="100%" height="175" border="0" align="center">
  211.                 <tr>
  212.                   <td width="68%" height="21">知识点1: </td>
  213.                 </tr>
  214.                 <tr>
  215.                   <td height="35">
  216. <select name=KnowPoint1 id="select7">
  217.                       <option value=-1>----未选择----</option>
  218.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  219.                     </select></td>
  220.                 </tr>
  221.                 <tr>
  222.                   <td height="25">知识点2:</td>
  223.                 </tr>
  224.                 <tr>
  225.                   <td height="36">
  226.                     <select name=KnowPoint2 id="select12">
  227.                       <option value=-1>----未选择----</option>
  228.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  229.                     </select></td>
  230.                 </tr>
  231.                 <tr>
  232.                   <td height="21">知识点3:</td>
  233.                 </tr>
  234.                 <tr>
  235.                   <td height="23">
  236. <select name=KnowPoint3 id="select16">
  237.                       <option value=-1>----未选择----</option>
  238.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  239.                     </select></td>
  240.                 </tr>
  241.               </table>
  242.             </td>
  243.           </tr>
  244.         </table></td>
  245.   </tr>
  246. </table>
  247. </form>
  248. </body>
  249. </html>
  250. <%}
  251. catch(Exception e){
  252.     System.out.print(e.toString());
  253. }
  254. finally{
  255.     DBCon.dropConnection();
  256. }
  257. %>