<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.exam.domain.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <script type="text/javascript">
   function subForm(currentPage,paperId){
   sForm.action="studentExam.do";
   //alert(currentPage);
   var cValue = document.getElementById("currentPage");
   cValue.value = currentPage;
   //alert(cValue.value) ;
   //sForm.currentPage.value=currentPage;
   //sForm.paperId.value=paperId;
   var pValue = document.getElementById("paperId");
   pValue.value = paperId ;
   //alert(pValue.value) ;
   document.getElementById("sForm").submit();
   //sForm.submit();
       }
  </script><!-- 怎么把下面minute 和second  的值赋值给js里面的var minute var hour -->
  
  <script type="text/javascript">
       var second = 10;
            var minute = 10;
            var hour = 0; var min = document.form.min.value;
var sec = document.form.sec.value;
 
if(min != "" && sec != "") {
var second = min;
             var minute = sec;
             var hour = 0;


            
            idt = window.setTimeout("interval();", 1000);
            function interval(){
                second--;
                if (second == -1) {
                    second = 59;
                    minute -= 1;
                }
                if (minute == -1) {
                    minute = 59;
                    hour -= 1;
             }
if(hour==0&&minute==0&&second==0){
document.sForm.input.value = minute + "分" + second + "秒";
window.alert("停!!!!");

}else{
  idt = window.setTimeout("interval();", 1000);
}
if (minute==10&&second==0) {
window.alert("您还有10分钟的答题时间,10分钟中后系统将自动帮你提交");
}
            document.sForm.input.value = minute + "分" + second + "秒";
                   
           }
   </script>
    <title></title>
  </head>
  
  <body onload="javascript:interval()">
  
   minute = ${requestScope.minute}
   second = ${requestScope.second}
  
   <form name="form";>
   <input type="text" name="min" value="${requestScope.minute}">
   <input type="text" name="sec" value="${requestScope.second}">
   </form>
  
   <center>
     <c:if test="${page.currentPage > 1}">
     <a onclick="subForm('${page.currentPage - 1 }','${paperId }')" style="text-decoration: underline; color: blue; cursor: pointer">上一页</a>
     </c:if>
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <font color="red">
     当前页:${page.currentPage }/总页数:${page.totalPage }
     </font>
     <c:if test="${page.currentPage < page.totalPage}">
     <a onclick="subForm('${page.currentPage + 1 }','${paperId }')" style="text-decoration: underline; color: blue; cursor: pointer">下一页</a>
     </c:if>
    </center>
    <hr/>   <form action="" method="post" name="sForm" id="sForm">
  
   <!--时间控件 -->
   <p> 
剩余时间:<input type="text" name="input" id="time" size="10" readonly="readonly"><br> 
</p>
<input type="text" name="currentPage" id="currentPage"/>
      <input type="text" name="paperId" id="paperId"/>

   <%
   PaperPage p = (PaperPage)request.getAttribute("page") ;
   for(int i=0;i<p.getList().size();i++){
   Question que = p.getList().get(i) ;
   int num = i+1+((p.getCurrentPage()-1)*PaperPage.ITEM_PER_PAGE);
   String str = "题目"+num;
   String [] arr = (String [])session.getAttribute(str);
   %>
  
   <table border="0">
    <tr>
    <td>
    题号:<%=num %>&nbsp;&nbsp;&nbsp;&nbsp;[<%=que.getQuestionType() %>]
    类型:<%=que.getSubject() %>&nbsp;&nbsp;&nbsp;&nbsp;本题分数:<font color="red"><%=que.getQuestionScore() %></font>
    </td>
    </tr>
    <tr></tr><tr></tr>
    <tr>
    <td>&nbsp;<%=que.getQuestionTitle() %>
    </td>
    </tr>
<%
if("easyAnswer".equals(que.getQuestionType())){
String s="";
if(arr!=null){
s=arr[0];
}
%>
<tr>
<td>
<textarea rows="5" cols="30" name="<%=str %>"><%=s %></textarea>
</td>
</tr>
<%
}else{
String choices[] = que.getChoice().split("_#") ;
for(int j=0;j<choices.length;j++){
if("singleChoice".equals(que.getQuestionType())){
String checked = "";
String choice = (char)(65+j)+"";
if(arr!=null && choice.equals(arr[0])){
checked = "checked";
}
%>
<tr>
<td>
<input type="radio" name="<%=str %>" value="<%=(char)(65+j) %>" <%=checked %> />
<%=(char)(65+j) %>&nbsp;&nbsp;&nbsp;<%=choices[j] %>
</td>
</tr>
<%
}else{
String checked = "";
String choice = (char)(65+j)+"";
if(arr!=null ){
for(int k=0;k<arr.length;k++){

if(choice.equals(arr[k])){
checked = "checked";
}
}
}
%>
<tr>
<td>
<input type="checkbox" name="<%=str %>" value="<%=(char)(65+j) %>" <%=checked %> />
<%=(char)(65+j) %>&nbsp;&nbsp;&nbsp;<%=choices[j] %>
</td>
</tr>
<%
}
}
}
 %>
       </table>
     <hr/>
    <%
   }
    %>
    
    </form>
    <center>
     <c:if test="${page.currentPage > 1}">
     <a onclick="subForm('${page.currentPage - 1 }','${paperId }')" style="text-decoration: underline; color: blue; cursor: pointer">上一页</a>
     </c:if>
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <font color="red">
     当前页:${page.currentPage }/总页数:${page.totalPage }
     </font>
     <c:if test="${page.currentPage < page.totalPage}">
     <a onclick="subForm('${page.currentPage - 1 }','${paperId }')" style="text-decoration: underline; color: blue; cursor: pointer">下一页</a>
     </c:if>
    </center>
  </body>
</html>