?? unittestshow.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*"%>
<%@ page import="jinghua.*"%>
<jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
</jsp:useBean>
<%!
String studentID;
boolean debug=false;
StringBuffer dbmsg=new StringBuffer();
%>
<%
//StudentID
try{
studentID=(String)session.getAttribute("studentID");
//Tools.showalert(studentID,out);
if(studentID==null){
throw new Exception();
}
}catch(Exception e){
Tools.showalert("您還沒有登錄,或連接超時,請重新登錄!",out);
Tools.showJS("window.open('../login.jsp','_self')",out);
}
//studentID=1;
String gradeID=""+request.getParameter("Grade");
String subjectID=""+request.getParameter("Subject");
String knowpointID=""+request.getParameter("KnowPoint");
gradeID=gradeID.trim();
subjectID=subjectID.trim();
knowpointID=knowpointID.trim();
String sql="";
String title="";
String strClass="";
ResultSet rs=null;
try{
Connection con=DBCon.getConnection();
sql="select grade.name as gn,subject.name as sn, knowpoint.name as kn "+
"from grade,subject,knowpoint where grade.note="+"'"+gradeID+"'"+" and subject.id="+
subjectID+" and knowpoint.id="+knowpointID;
PreparedStatement pstmt=con.prepareStatement(sql);
rs=pstmt.executeQuery();
if(rs.next()){
strClass="計算機等級:"+rs.getString("gn")+"<br>科目:"+rs.getString("sn")+"<br>知識點:"
+rs.getString("kn");
}
if(debug){
out.print(strClass);
}
pstmt.close();
rs.close();
sql="select id,paper,title from test where status=2 and gradenote="+"'"+gradeID+"'"+" and subid="+subjectID+
" and ((knowpointid1="+knowpointID+") or (knowpointid2="+knowpointID+
") or (knowpointid3="+knowpointID+")) order by id";
pstmt=con.prepareStatement(sql);
rs=pstmt.executeQuery();
if(debug) {
dbmsg.append("<br>sql="+sql);
out.print(dbmsg.toString());
}
if (rs.next()){//符合條件的記錄 //試題ID@答案@分數@難易度; 一道試題的格式,以分號結束
rs.beforeFirst();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK
href="../common/css/style.css" type=text/css rel=stylesheet>
<title>單元測試-選擇試題</title>
</head>
<body text=black bgColor=white leftMargin=0 topMargin=10 marginheight="0"
marginwidth="0">
<DIV align=center>
<FORM name="form1" action="UnitTestPaper.jsp" method="post">
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top bgColor=#fbffee> <P> </P></TD>
<TD vAlign=top width=480>
<TABLE width=480 border=0 cellPadding=0 cellSpacing=0 class="tboutline">
<TBODY>
<TR align=middle>
<TD height=30 align="left" class=p2>
<p> </p>
<p> </p>
<p><strong><B><%=strClass%>
</B> </strong> </p>
<p> </p></TD>
</TR>
<%while(rs.next()){%>
<TR bgColor=#cccc99 class="trcolor">
<TD class=p2 height=30> <P><B><FONT color=#333300>
<a href="UnitTestPaper.jsp?testID=<%=rs.getInt("ID")%>&stuID=<%=studentID%>"
title="<%=rs.getString("title")%>"
target="mainFrame">★ <%=rs.getString("title")%>
</a></FONT></B></P></TD>
</TR>
<TR>
<TD class=p2><P> </P></TD>
</TR>
<%
}
rs.close();
pstmt.close();
%>
</TBODY>
</TABLE></TD>
<TD vAlign=top width=140 bgColor=#fbffee> </TD>
</TR></TBODY></TABLE>
</FORM>
</DIV>
</body>
</html>
<%
}else{
Tools.showalert("沒有從數據庫找到符合條件的試卷,請重新設定查詢條件",out);
//Tools.goback(out);
}
}catch(SQLException e){
out.print("<br>SQL Error:sql="+sql+"<br>"+e.toString());
}catch(Exception e){
out.print(e.toString() );
}
finally{
DBCon.dropConnection();
}
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -