?? unittestshow.jsp
字號(hào):
<%@ 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("您還沒(méi)有登錄,或連接超時(shí),請(qǐng)重新登錄!",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="年級(jí):"+rs.getString("gn")+" 科目:"+rs.getString("sn")+" 知識(shí)點(diǎn):"
+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@答案@分?jǐn)?shù)@難易度; 一道試題的格式,以分號(hào)結(jié)束
rs.beforeFirst();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>單元測(cè)試-選擇試題</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 cellSpacing=0 cellPadding=0 width=480 border=0>
<TBODY>
<TR align=middle>
<TD class=p2 height=30>
<font color="#74a8d1">
<strong><B>
<%=strClass%>
</B>
</strong>
</font></TD>
</TR>
<%while(rs.next()){%>
<TR bgColor=#cccc99>
<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="_blank">★ <%=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("沒(méi)有從數(shù)據(jù)庫(kù)找到符合條件的試卷,請(qǐng)重新設(shè)定查詢(xún)條件",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();
}
%>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -