?? mn_test_rs.jsp
字號:
//如果完成了正式考試,則在mn_history中增加記錄,表明考生完成了這次測試
sql="select * from mn_history where stu_id='"+studentID+"' and mn_test_id="+mn_testID;
try{
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next()){
rs.close();
stmt.close();
}else{
rs.close();
stmt.close();
//查詢這次正式考試的總分及積各科目分數(shù)
sql=" SELECT `subject`.`id` AS `subid`,`subject`.`Name` AS `subname`, "+
" FORMAT(`test`.`mark`,0) AS `totalmark`, FORMAT(`mn_scores`.`score`,0) AS `score` "+
" FROM `mn_scores` LEFT OUTER JOIN `subject` ON (`mn_scores`.`sub_id` = `subject`.`ID`)"+
" LEFT JOIN `test` ON (`mn_scores`.`test_id` = `test`.`id`)"+
" WHERE (`mn_test_id` = "+mn_testID+") AND (`stu_id` = '"+studentID+"')"+
" ORDER BY `subid`";
int his_subnum=0;
int hisreal=0;
sb=new StringBuffer();//化學:50#物理:20#英語:40#
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next()){
his_subnum++;
hisreal+=rs.getInt("score");
sb.append(rs.getString("subname")+":"+rs.getString("score")+"#");
}
rs.close();
stmt.close();
sql="insert into mn_history(stu_id,mn_test_id,test_date,totalmark,submark,sub_num) "+
" values('"+studentID+"',"+mn_testID+",CURRENT_DATE,"+hisreal+",'"+sb.toString()+"',"+
his_subnum+")";
stmt=con.createStatement();
stmt.executeUpdate(sql);
}
if(debug){
out.print("<br>insert into mn_history sql="+sql);
}
}
catch(SQLException se){
out.print("<br>insert into mn_history sql="+sql);
out.print("<br>"+se.toString());
}
catch(Exception e){
out.print("<br>insert into mn_history sql="+sql);
out.print("<br>"+e.toString());
}
//增加參加考試的人數(shù)
//獲取參加正式考試的總?cè)藬?shù),而且必須完成這次正式考試的全部測試
int testPeople=0;
sql="SELECT count(*) as tested from mn_history where mn_test_id="+mn_testID;
try{
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next()){
testPeople=rs.getInt("tested");
}
else{
testPeople=0;
}
rs.close();
stmt.close();
}
catch(SQLException se){
out.print("<br> query mn_history error sql="+sql);
out.print("<br>"+se.toString());
}
catch(Exception e){
out.print("<br> query mn_history error sql="+sql);
out.print("<br>"+e.toString());
}
//有人做完正式考試
//將參加正式考試的總?cè)藬?shù)寫入數(shù)據(jù)庫
try{
sql="update mn_test set testpeople="+testPeople+" where id="+mn_testID;
stmt=con.createStatement();
stmt.executeUpdate(sql);
stmt.close();
}
catch(SQLException se){
out.print("<br> update mn_test.testpeople error sql="+sql);
out.print("<br>"+se.toString());
}
catch(Exception e){
out.print("<br> update mn_test.testpeople error sql="+sql);
out.print("<br>"+e.toString());
}
if(debug){
out.print("<br>mn_test totalpeople sql="+sql);
out.print("<br>mn_test totalpeople="+testPeople);
}
}//end if(have_test==sub_num)
}
}catch(SQLException se){
out.print("<br> query mn_scores error sql="+sql);
out.print("<br>"+se.toString());
}
catch(Exception e){
out.print("<br> query mn_scores error sql="+sql);
out.print("<br>"+e.toString());
}
}//end if(valid=1)
//試題記錄集
sql=testIDs.toString().substring(0,testIDs.length()-1);
sql="select id,questtext,tip,mark from question where id in ("+sql+") order by id";
pstmt=con.prepareStatement(sql);
rs=pstmt.executeQuery();
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>成績查詢 | 考試成績 | | 單項選擇題</title>
<script>
function goLogin()
{
top.location="/pctest/login.jsp";
}
</script>
<link rel="stylesheet" type="text/css" href="../css.css">
</head>
<body>
<center>
<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2" height="25">
<tr>
<td width="100%" height="29" style="border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom: 1px solid #000000">
<img border="0" src="../images/cxcj.gif"></td>
</tr>
<tr>
<p> </p>
</tr>
</table>
<p> </p>
</center>
<div align="center">
<center>
<table cellspacing="1" style="border-collapse: collapse" bordercolor="#799AE1" width="469" id="AutoNumber2" border="1">
<form method="POST" action=""><tr>
<td width="100%" height="25" bgcolor="#6699CC" background="images/admin_bg_1.gif" bordercolor="#799AE1">
<p align="center"><b> <font color="#FFFFFF">成績單</font></b></td>
</tr>
<tr>
<td width="100%" height="160" bgcolor="#FFFDE8" bordercolor="#799AE1">
<p align="center"> </p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="202">
<tr>
<td width="8%" height="28"> <p align="right">考生編號:</td>
<td height="28" colspan="4"> <%=studentID%></td>
</tr>
<tr>
<td width="8%" height="29"> <p align="right">姓
名:</td>
<td height="29" colspan="4"><%=name%> </td>
</tr>
<tr>
<td width="8%" height="29"> <p align="right">得 分:</td>
<td width="13%" height="29">卷面分:</td>
<td width="23%"><%=testmark%> </td>
<td width="15%">百分制:</td>
<td width="41%">
<% DecimalFormat df=new DecimalFormat("###");
String r=df.format(testmark/totalmark*100);
out.print(r);
%>
</td>
</tr>
<tr>
<td width="8%" height="29"> <p align="right">答 錯:</td>
<td height="29" colspan="4"><%=error%> </td>
</tr>
<tr>
<td width="8%" height="29"> <p align="right">答 對:</td>
<td height="29" colspan="4"><%=correct%> </td>
</tr>
<tr>
<td height="29"> <p align="right">正確答案:</p></td>
<td height="29" colspan="4"><%=Answer.toString() %> </td>
</tr>
<tr>
<td height="29"><p align="right">您的答案:</p></td>
<td height="29" colspan="4"><%=SubAns.toString()%> </td>
</tr>
</table>
<p align="center"> </p>
</td>
</tr>
<tr>
<td width="100%" height="25" bgcolor="#FFFFFF" bordercolor="#799AE1"> <p align="center">
<INPUT class="s02" onClick="window.close()" type=button value=返回 name=close2>
<span lang="en-us"> </span>
<INPUT class="s02" onClick="goLogin" type=button value=重新登錄 name=close22>
</td>
</tr>
</form>
</table>
</center>
</div>
<center><form name="viewdatabase" ACTION="" method="post">
<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#799AE1" width="100%" id="AutoNumber1" height="82">
<tr class="trh">
<td width="44" align="center" bgcolor="#799AE1" height="24">
<font color="#FFFFFF"><b>序號</b></font></td>
<td align="center" bgcolor="#799AE1" width="592" height="24"> <p align="center"><font color="#FFFFFF">
<b>單項選擇題(共<%=testnum%> 題,<%=totalmark%>分)</b></font></td>
</tr>
<% testNumber=0;
while(rs.next()){%>
<tr class="trh1">
<td align="center" height="35" width="44">
<center>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <div align="center">
<%out.print(testNumber+1);%>.
</div></td>
</tr>
<tr>
<td><div align="center">(<%=arrMark[testNumber]%>分)</div></td>
</tr>
</table>
</center> </td>
<td align="left" width="592" height="35"><br>
<%
out.print("正確答案是"+arrAnswer[testNumber]+", ");
if(arrTF[testNumber].equals("T")){
out.print("您的答案是"+arrSubAns[testNumber] +"<br>");
}else{
out.print("<font color=Red>您的答案是"+arrSubAns[testNumber] +"</font><br>");
}
out.print("原題目:<br>"+rs.getString("questtext"));
out.print("<br>提示:<br>"+""+rs.getString("tip"));
testNumber++;
%>
</td>
</tr>
<%}
rs.close();
pstmt.close();
%>
<tr>
<td align="center" bgcolor="#FFFFFF" height="16" width="640" colspan="2" bordercolor="#FFFFFF">
<p align="center">
<INPUT class="s02" onClick="window.close()" type=button value=返回 name=close>
</p>
</td>
</tr>
</table>
</form>
</center>
<center> <form ACTION="" METHOD="GET">
<table style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
<tr>
<td width="576">
<p ALIGN="center"> </p>
<p> </td>
</tr>
</table>
</form>
</center>
</body>
</html>
<%}
catch (Exception e){
if(debug){
Tools.debugmsg("<BR>Exception:"+e.toString() ,out);
}
}
finally{
DBCon.dropConnection();
}
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -