📄 exam.jsp
字号:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="sys.DB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.sql.*"%>
<%@ page import="java.util.Date"%>
<%@page import="com.sun.org.apache.bcel.internal.generic.NEW"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.Catch"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>试卷</title>
<script type="text/javascript">
function check()
{
if(confirm('你真的要提交吗?'))
{
form1.submit();
}
}
var h,m,s,hstr,mstr,sstr,timestr;
var etime = 45 * 60; //总秒数
function timer()
{
h = Math.floor(etime / 3600); //时
m = Math.floor(etime / 60) % 60; //分
s = Math.floor(etime % 60); //秒
h < 0 ? h = 0 : h = h;
m < 0 ? m = 0 : m = m;
s < 0 ? s = 0 : s = s;
h.toString().length < 2 ? hstr = "0" + h.toString() : hstr = h; //1显示01
m.toString().length < 2 ? mstr = "0" + m.toString() : mstr = m; //1显示01
s.toString().length < 2 ? sstr = "0" + s.toString() : sstr = s; //1显示01
timestr = hstr + ":" + mstr + ":" + sstr;
//txt.value = timestr;
document.getElementById("showTime").innerText= "离考试结束还有:"+timestr;
etime = etime - 1;
//考试时间剩余五分钟时,提示时间变红
if(etime <= 5*60)
document.getElementById("showTime").style.color="red";
if(etime <= -5*60)
form1.submit();
}
</script>
<style type="text/css">
html,body{
width:100%;
height:100%;
margin:0px;
padding:0px;
overflow:hidden;
}
#Main{
position:relative;
top:0px;
left:0px;
/*padding-left:20px;*/
width:100%;
height:100%;
overflow:auto;
z-index:1;
}
#ToolBar{
position:absolute;
top:0px;
right:0px;
width:100%;
height:36px;
/*background:#00FFFF;*/
z-index:2;
font-size:18px;
overflow:hidden;
background-image:url(../images/zizhu_02.gif);
}
.s12green{
color:#4f7500;
font-size:12px;
}
.s14black{
font-size:14px;
}
</style>
</head>
<body onLoad="window.setInterval('timer()',1000);">
<div id="ToolBar">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="font-size:12px; font-weight:bold; padding-left:50px; padding-right:30px;">欢迎使用驾校无纸化考试学习系统</td>
<td style="background-image:url(../images/zizhu_04.jpg); width:88px; height:32px; font-size:12px; color:#395500;" align="center" valign="middle">
<%
String test_type = (String)session.getAttribute("test_type");
if(test_type != null)
out.print("模拟考试");
else
out.print("正式考试");
%>
</td>
<td style="padding-left:50px; color:#cc6600; font-size:12px;">进入自主练习模式,分章节逐题练习</td>
<td style="font-size:12px; color:#645a44; padding-left:100px;" align="right"><div id="showTime"></div></td>
</tr>
</table>
</div>
<div id="Main">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td height="36"></td><td></td></tr>
<tr>
<td width="20"></td>
<td class="s12green" height="34">——您已进入模拟考试模式,请勿关闭浏览器或点击其它功能,否则将导致模考不能继续。仔细做答,右上角倒计时为0时将自动提交试卷。</td>
</tr>
<tr>
<td></td>
<td bgcolor="#f5f4f1" style="font-size:12px; padding-left:10px;" height="39">试卷总分:100分 试卷总题:100道 题目类型:选择题 每题分值:1分</td>
</tr>
<tr>
<td></td>
<td class="s12green" style="padding-top:10px;">——请仔细审题,选择您认为正确的选项</td>
<tr>
</table>
<%
//session.setAttribute()
if(session.getAttribute("examer_no")==null)
response.sendRedirect("login.jsp");
String examer_no = (String)session.getAttribute("examer_no");
%>
<%
DB db = new DB();
%>
<%
Connection con1 = db.getConnection();
ResultSet ifpaper_exist = con1.createStatement().executeQuery("select * from exam_paper");
//如果存在试卷,直接读取
if(ifpaper_exist.next())
{
int questionIndex = 1;
out.print("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding-left:20px;\">");
out.print("<form id=\"form1\" name=\"form1\" method=\"post\" action=\"judge.jsp\">");
try{
do
{
out.print("<tr><td align=\"center\" style=\"padding-top:15px;padding-bottom:15px;\"><img src=\"../images/zizhu_09.gif\"></td></tr>");
out.print("<tr><td class=\"s14black\" style=\"padding-left:20px;\">");
CallableStatement getquestion = con1.prepareCall("{call getquestion(?)}");
getquestion.setString("quest_id",ifpaper_exist.getString("question_id").trim());
//out.print(ifpaper_exist.getString("question_id").trim()+"<br>");
getquestion.executeQuery();
ResultSet question = getquestion.getResultSet();
question.next();
out.print(questionIndex+"."+question.getString("quest")+"<br>");
if(question.getString("keyA").trim() != "")
out.print("<input type=radio name=\""+ifpaper_exist.getString("question_id").trim()+"\" value=\""+1+"\" />"+question.getString("keyA")+"<br>");
if(question.getString("keyB").trim() != "")
out.print("<input type=radio name=\""+ifpaper_exist.getString("question_id").trim()+"\" value=\""+2+"\" />"+question.getString("keyB")+"<br>");
if(question.getString("keyC")!=null&&!question.getString("keyC").trim().equals(""))
out.print("<input type=radio name=\""+ifpaper_exist.getString("question_id").trim()+"\" value=\""+3+"\" />"+question.getString("keyC")+"<br>");
if(question.getString("keyD")!=null&&!question.getString("keyD").trim().equals(""))
out.print("<input type=radio name=\""+ifpaper_exist.getString("question_id").trim()+"\" value=\""+4+"\" />"+question.getString("keyD")+"<br>");
questionIndex ++;
out.print("</tr></td>");
}while(ifpaper_exist.next());
out.print("<tr><td align=\"center\" style=\"padding-top:15px;padding-bottom:15px;\"><img src=\"../images/zizhu_09.gif\"></td></tr>");
out.print("<tr><td height=\"50\" style=\"color:red;font-size:14px;font-weight:bold;\"><input type=\"button\" value=\"交卷\" onclick=\"check()\"/>注意:交卷之后无法返回修改答案,请谨慎选择。</td></tr>");
//out.print("<tr><td height=\"50\"></td></tr>");
out.print("</form>");
out.print("</table>");
}
catch(Exception e)
{
out.print(e.toString());
}
}
else
{
try
{//抽取试卷
out.print("正在生成试卷,请稍候。。");
Connection con = db.getConnection();
CallableStatement getencodelist = con.prepareCall("{call getencodelist()}");
//callableStatement.setInt(1,100);
getencodelist.executeQuery();
ResultSet rs = getencodelist.getResultSet();
while(rs.next())
{
CallableStatement getpaper = con.prepareCall("{call gettestpaper(?)}");
getpaper.setString(1,rs.getString("encode"));
getpaper.executeQuery();
ResultSet question = getpaper.getResultSet();
while(question.next())
{
db.updateData("insert into exam_paper(examer_no,question_id,right_answer) values('"+examer_no+"','"+question.getString("quest_id").trim()+"','"+question.getString("answer").trim()+"')",con);
//out.print(question.getString("quest_id").trim());
}
}
//Exception e = new Exception();
//throw e;
//初始化考试状态
if(test_type == null)
{
//如果状态为考试的话,执行以下初始化代码
Date date = new Date();
db.updateData("update exam_examinee set begin_time='"+date.toLocaleString()+"' where examer_no='"+examer_no+"'",con);
db.updateData("update exam_examinee set status='1' where examer_no='"+examer_no+"'",con);
}
out.print("试题抽取完毕,正在打开试卷。。");
out.print("<script language=javascript>window.location.reload()</script>");
}
catch(Exception e)
{
Connection con = db.getConnection();
db.updateData("delete from exam_paper where examer_no = '"+examer_no+"'",con);
out.print("抽屉出错,<a href="+"javascript:window.location.reload();"+">点击这里刷新</a>");
}
}
%>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -