📄 judge.jsp
字号:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="sys.DB"%>
<%@page import="java.sql.*" %>
<%@ page import="java.util.Date"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<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>
<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">
<%
String examer_no = "2";
DB db = new DB();
Connection con = db.getConnection();
String answer = new String();
int score = 0;
%>
<%
ResultSet rs = db.getResultSet("select question_id from exam_paper where examer_no='"+examer_no+"'",con);
while(rs.next())
{
answer = request.getParameter(rs.getString("question_id").trim());
//out.print(answer+"<br>");
if(answer!=null)
db.updateData("update exam_paper set examer_answer='"+answer.trim()+"' where question_id='"+rs.getString("question_id").trim()+"'",con);
}
rs.close();
ResultSet result = db.getResultSet("select question_id,right_answer,examer_answer from exam_paper where examer_no='"+examer_no+"'",con);
int questionIndex = 1;
out.print("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding-left:20px;\">");
out.print("<tr><td height=\"36\"></td><td></td></tr>");
while(result.next())
{
if(result.getString(2)!=null&&result.getString(3)!=null)
if(result.getString(2).trim().equals(result.getString(3).trim()))
score ++;
else
{
if(test_type != null)
{//如果为模拟考试,则列出出错信息
out.print("<tr><td width=\"20\"></td><td align=\"center\" style=\"padding-top:15px;padding-bottom:15px;\"><img src=\"../images/zizhu_09.gif\"></td></tr>");
out.print("<tr><td width=\"20\"></td><td class=\"s14black\" style=\"padding-left:20px;\">");
ResultSet question = db.getResultSet("select * from exam_question where quest_id='"+result.getString(1).trim()+"'",con);
question.next();
out.print(questionIndex+"."+question.getString("quest")+"<br>");
if(question.getString("keyA").trim() != "")
out.print("<input type=radio value=\""+1+"\" />"+question.getString("keyA")+"<br>");
if(question.getString("keyB").trim() != "")
out.print("<input type=radio value=\""+2+"\" />"+question.getString("keyB")+"<br>");
if(question.getString("keyC")!=null&&!question.getString("keyC").trim().equals(""))
out.print("<input type=radio value=\""+3+"\" />"+question.getString("keyC")+"<br>");
if(question.getString("keyD")!=null&&!question.getString("keyD").trim().equals(""))
out.print("<input type=radio value=\""+4+"\" />"+question.getString("keyD")+"<br>");
out.print("</tr></td>");
out.print("<tr><td width=\"20\"></td><td bgcolor=\"#f5f4f1\" style=\"font-size:12px; padding-left:10px;\" height=\"39\">您的答案是"+result.getString(3).trim()+"      <font color=red>正确答案是"+result.getString(2).trim()+"</font>      帮助:"+question.getString("quest_discuss").trim()+"</tr></td>");
}
}
questionIndex ++;
}
out.print("</table>");
//写入考生状态和成绩
if(test_type == null)
{
Date date = new Date();
db.updateData("update exam_examinee set end_time='"+date.toLocaleString()+"' where examer_no='"+examer_no+"'",con);
db.updateData("update exam_examinee set status='2' where examer_no='"+examer_no+"'",con);
db.updateData("update exam_examinee set grade='"+score+".00"+"' where examer_no='"+examer_no+"'",con);
}
if(score >= 60)
out.print("<font color=green style=\"font-size:20px;padding-left:20px;\">恭喜您!考试合格</font><br><font color=green style=\"font-size:20px;padding-left:20px;\">您的分数是:"+score+"分</font>");
else
out.print("<font color=red style=\"font-size:20px;padding-left:20px;\">考试不合格!</font><br><font color=red style=\"font-size:20px;padding-left:20px;\">您的分数是:"+score+"分</font>");
if((String)session.getAttribute("test_type") != null)
{
//如果为模考则删除相关考试信息,以备下一次考试
db.updateData("delete from exam_paper where examer_no = '"+examer_no+"'",con);
}
//out.print();
%>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -