⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ontestinput.jsp

📁 培训考试系统代码
💻 JSP
字号:
<%@  page language="java" contentType= "text/html; charset=gb2312"%>
<%@ page import = "com.huawei.icd30.common.db.*"%>
<%@ page import = "com.huawei.icd30.agt.util.*" %>
<%@ page import = "java.util.*" %>

  <% String maxCountStr = (String)request.getAttribute("maxCount");
     String userCountStr = (String)request.getAttribute("userCount");
     String examTimeStr = (String)request.getAttribute("examTime");
     int maxCount = 0;
     int leaveCount = 0;
     int examTime = 0;
     if(maxCountStr != null)
     {
         maxCount = Integer.parseInt(maxCountStr);
         leaveCount = maxCount - Integer.parseInt(userCountStr);
     }

     if(examTimeStr != null)
     {
        examTime = Integer.parseInt(examTimeStr);
     }
  %>

<!-- <title>业务代表管理系统考试页面</title>-->

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
	SCROLLBAR-FACE-COLOR: #d6efff; SCROLLBAR-HIGHLIGHT-COLOR: #9E9E9E; SCROLLBAR-SHADOW-COLOR: #9E9E9E; SCROLLBAR-3DLIGHT-COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #666666; SCROLLBAR-TRACK-COLOR: #d6efff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff}
</STYLE>
<title>考试题自测页面 </title>
<link href="/agt/public/css/gb.css" rel="stylesheet" type="text/css">
<script LANGUAGE="JAVASCRIPT">

var time = <%=examTime%>;
var time_total = time * 60;
var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;


function get_time_spent ()
{ 

var time_now = new Date();
return((time_now.getTime() - clock_start)/1000); 
}


function show_secs () // show the time user spent on the side
{ 
  var i_total_secs = Math.round(get_time_spent()); 

  var i_secs_spent = i_total_secs % 60;

  var i_mins_spent = Math.round((i_total_secs-30)/60); 

  var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);
  var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);

  if(time != 0)
  { 
    if (time_total - i_total_secs == 600) alert ("考试还剩下10分钟了!!!");
    if (time_total == i_total_secs) document.onexamform.submit();
  }

   document.onexamform.time_spent.value = s_mins_spent + ":" + s_secs_spent;

  window.setTimeout('show_secs()',1000); 
}

</script>
<body bgcolor="B7D5F9" leftmargin="0" topmargin="00" marginwidth="0" marginheight="0" onLoad=" window.setTimeout('show_secs()',1);" oncontextmenu=return(false); onselectstart="return false"  onbeforeprint="document.body.style.display = 'none';" >
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><p align="left"><font color="#FF0000" face="宋体"><br>
                          自测考试,点击提交按钮可查看所得分数与答案</font></p></td>
  </tr>
</table>
<form name="onexamform" method="POST" action="/OnlineExam.do">
  <table width="550" border="0" cellpadding="3" cellspacing="1" class="table-cs1" align="center">

  <tr>
      <td height="25" align="center" class="td-cs1">试卷名称:<%=request.getAttribute("title")%>
      </td>
  </tr>

</table>

    <input type="hidden" name="opeType" value="<%=OperatorFlagCode.ONLINEEXAM_TESTDEAL%>">
    <input type="hidden" name="paperId" value="<%=request.getParameter("paperId")%>">
    <input type="hidden" name="lessonId" value="<%=request.getParameter("lessonId")%>">
  <table width="550" border="0" cellpadding="3" cellspacing="1" class="table-cs1" align="center">
    <%
        SysResultSet rs  =  (SysResultSet)request.getAttribute("ONLINETEST-GETTEST-RESULTSET");
        request.getSession().setAttribute("ONLINETEST-GETTEST-RESULTSET",rs);
        String optionRsSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        if(rs != null)
        {   for(int i=0;rs.setRecord(i)&&i<rs.getMetaData().getRecordCount();i++)
            {
             //4:试题类型 5:试题类型名称,1:试题内容,9:试题选项,8:试题分数,10:试题答案
      %>
                <tr>

      <td width="20%" align="center" valign="top" class="td-cs2" ><%=i+1%>、(<%=rs.getString(5)%>)</td>
                <input type="hidden" name="testIds" value="<%=rs.getString(0)%>">
                <input type="hidden" name="testType" value="<%=rs.getString(4)%>">
                <input type="hidden" name="score" value="<%=rs.getString(8)%>">
                <input type="hidden" name="reply" value="">
                <input type="hidden" name="result" value="<%if(rs.getInt(4)==1 || rs.getInt(4)==2 || rs.getInt(4)==3){%><%=rs.getString(10)%><%}%>">
      <td valign="top" class="td-cs2" style="word-break:break-all">&nbsp;<%=rs.getString(1)%>&nbsp;(<%=rs.getString(8)%>分)
<table border="0" cellpadding="3" cellspacing="0">
          <%
                    //对试题选项进行处理
                    int testType = Integer.parseInt(rs.getString(4));
                    int loc = 0;

                    StringTokenizer stoken = new StringTokenizer(rs.getString(9),"#");
                    while(stoken.hasMoreTokens())
                    {   String optionRs = optionRsSet.substring(loc,loc+1);
                        if(testType==1 || testType==2)
                        {
                    %>
                          <tr>

      <td class="td-cs2" width="30"></td>

      <td class="td-cs2" ><%=optionRs%>.<input type="radio" name="A<%=rs.getString(0)%>" value="<%=optionRs%>"><%=stoken.nextToken()%></td>
                          </tr>

                    <%
                        }
                        else if(testType==3)
                        {
                     %>
                          <tr>

      <td class="td-cs2" width="30"></td>

      <td class="td-cs2" ><%=optionRs%>.<input type="checkbox" name="A<%=rs.getString(0)%>" value="<%=optionRs%>"><%=stoken.nextToken()%></td>
                          </tr>
                     <%
                        }
                        else
                        {
                     %>
                          <tr>

      <td class="td-cs2" width="30"></td>

      <td class="td-cs2" ><%=optionRs%>.
              <textarea name="A<%=rs.getString(0)%>" cols="45" rows="<%=stoken.nextToken()%>" class="remark"></textarea></td>
                          </tr>
                     <%
                        }
                        loc++;
                    }

%>

</table>
 </td>
                </tr> <%             }
         }
     %>
</table>


                  
  <table width="550" border="0" cellspacing="0" cellpadding="8" align="center">
    <tr>

                      <td width="41%" align="right">
                        <table width="224" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr align="right">
                            <td width="107">&nbsp;</td>
                            <td width="109">
							<input name="submit" type="image" onclick="submitPaper();return false;" src="/agt/public/images/submit.gif" width="82" height="22" border="0" onmouseover="this.src='/agt/public/images/'+ this.name + '_2.gif';" onmouseout="this.src='/agt/public/images/'+ this.name + '.gif'"></td>
          </tr>
        </table>
                      </td>

                      <td width="59%">
                      
                      <input name="time_spent" type="text" class="input1" onFocus="this.blur()" size="10" ></td>
                            </tr>
                          </table>    </form>
<script language="javascript">

function submitPaper()
{
    var testIds = document.onexamform.testIds;
    var testType = document.onexamform.testType;
    var reply = document.onexamform.reply;


    for(var i=0;i<testIds.length;i++)
    {
        var replyItemStr = "document.onexamform.A" + testIds[i].value;

        replyItem = eval(replyItemStr);

        if(testType[i].value == "1" || testType[i].value == "2" || testType[i].value == "3")
        {//判断题 - 单选题-多选题

           for(var j=0;j<replyItem.length;j++)
           {
               if(replyItem[j].checked == true)
               {
                   reply[i].value =  reply[i].value + replyItem[j].value;
               }
           }
        }
        else
        {//填空题,问答题
           if(!(replyItem.length > 1))
           {//只有一条输入
               reply[i].value = replyItem.value;
               if(replyItem.value == "")
               {
                   reply[i].value = " ";
               }
           }
           else
           {//有多条输入
               reply[i].value = replyItem[0].value;
               if(replyItem[0].value == "")
               {
                  reply[i].value = " ";
               }
               for(var j=1;j<replyItem.length;j++)
               {
                   if( replyItem[j].value != "")
                   {
                      reply[i].value = reply[i].value + "#" + replyItem[j].value;
                   }
                   else
                   {
                      reply[i].value = reply[i].value + "#" + " ";
                   }
               }
           }

        }

    }

    if(!(testIds.length > 1))
    {//只有一道题

        var replyItemStr = "document.all.A"+testIds.value;
        replyItem = eval(replyItemStr);

        if(testType.value == "1" || testType.value == "2" || testType.value == "3")
        {//判断题 - 单选题-多选题
            for(var j=0;j<replyItem.length;j++)
           {
               if(replyItem[j].checked == true)
               {
                   reply.value =  reply.value + replyItem[j].value;
               }
           }
        }
        else
        {//填空题,问答题

           if(!(replyItem.length > 1))
           {
               reply.value = replyItem.value;
               if(replyItem.value == "")
               {
                   reply[i].value = " ";
               }
           }
           else
           {
               reply.value = replyItem[0].value;

               for(var j=1;j<replyItem.length;j++)
               {
                   if( replyItem[j].value != "")
                   {
                      reply[i].value = reply[i].value + "#" + replyItem[j].value;
                   }
                   else
                   {
                      reply[i].value = reply[i].value + "#" + " ";
                   }
               }
           }

        }

    }

    
    document.onexamform.submit();
}


</script>


</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -