From 5968f89d03e5714c59754d2274345a014f920ebf Mon Sep 17 00:00:00 2001 From: sishenjieshuo Date: Sat, 15 Feb 2025 14:30:24 +0800 Subject: [PATCH] 1 --- .idea/School-ST.iml | 33 +- .idea/dataSources.xml | 18 ++ .idea/libraries/lib.xml | 9 + .idea/webContexts.xml | 13 + conf/Catalina/localhost/School-ST.xml | 6 +- src/main/webapp/admin.jsp | 24 +- src/main/webapp/evaluate.jsp | 18 +- src/main/webapp/evaluationPage.jsp | 87 +++-- src/main/webapp/initializeDatabase.jsp | 2 +- src/main/webapp/loadCourses.jsp | 25 +- .../Catalina/localhost/School-ST/SESSIONS.ser | Bin 0 -> 267 bytes .../org/apache/jsp/evaluate_jsp.class | Bin 15294 -> 0 bytes .../org/apache/jsp/evaluate_jsp.java | 300 ------------------ 13 files changed, 150 insertions(+), 385 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 .idea/libraries/lib.xml create mode 100644 .idea/webContexts.xml create mode 100644 work/Catalina/localhost/School-ST/SESSIONS.ser delete mode 100644 work/Catalina/localhost/School-ST/org/apache/jsp/evaluate_jsp.class delete mode 100644 work/Catalina/localhost/School-ST/org/apache/jsp/evaluate_jsp.java diff --git a/.idea/School-ST.iml b/.idea/School-ST.iml index b23e517..16e0a48 100644 --- a/.idea/School-ST.iml +++ b/.idea/School-ST.iml @@ -1,41 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..42272ec --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,18 @@ + + + + + mysql.8 + true + com.mysql.cj.jdbc.Driver + jdbc:mysql://localhost:3306 + + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 0000000..02ccf5e --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/webContexts.xml b/.idea/webContexts.xml new file mode 100644 index 0000000..22eada7 --- /dev/null +++ b/.idea/webContexts.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/conf/Catalina/localhost/School-ST.xml b/conf/Catalina/localhost/School-ST.xml index 83ce4c1..5f7a038 100644 --- a/conf/Catalina/localhost/School-ST.xml +++ b/conf/Catalina/localhost/School-ST.xml @@ -1,2 +1,6 @@ - + + + + + diff --git a/src/main/webapp/admin.jsp b/src/main/webapp/admin.jsp index 091c83d..3ab6378 100644 --- a/src/main/webapp/admin.jsp +++ b/src/main/webapp/admin.jsp @@ -51,14 +51,20 @@ 平均得分 <% - try {//加载数据库驱动 - Class.forName("com.mysql.cj.jdbc.Driver");//连接数据库 - Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");//查询语句 - String sql = "SELECT t.name, AVG(e.total_score) as avg_score FROM teachers t JOIN evaluations e ON t.teacher_id = e.teacher_id GROUP BY t.teacher_id";//创建Statement对象 - Statement stmt = conn.createStatement();//执行查询 - ResultSet rs = stmt.executeQuery(sql);//遍历结果集 - while (rs.next()) {//输出结果 //老师姓名 //平均得分 - out.println("" + rs.getString("name") + "" + rs.getDouble("avg_score") + "");//关闭连接 + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456"); + String sql = "SELECT t.name, AVG(e.total_score) as avg_score FROM teachers t JOIN evaluations e ON t.teacher_id = e.teacher_id GROUP BY t.teacher_id"; + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery(sql); + while (rs.next()) { + // 使用 JSP 表达式输出内容 + %> + + <%= rs.getString("name") %> + <%= rs.getDouble("avg_score") %> + + <% } rs.close(); stmt.close(); @@ -70,4 +76,4 @@ - \ No newline at end of file + diff --git a/src/main/webapp/evaluate.jsp b/src/main/webapp/evaluate.jsp index c8a8bd7..2ac763f 100644 --- a/src/main/webapp/evaluate.jsp +++ b/src/main/webapp/evaluate.jsp @@ -23,7 +23,7 @@ border-radius: 10px; /* 圆角 */ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影 */ text-align: center; /* 文本居中对齐 */ - } + }vv /* 表单样式 */ .form-group { margin-bottom: 15px; /* 表单组之间的间距 */ @@ -112,6 +112,22 @@ courseSelect.innerHTML = ""; // 清空课程下拉框 } } + function loadC(teacher) { + const courseSelect = document.getElementById("course"); // 获取课程下拉框 + + if (teacher) { + fetch(`loadCourses.jsp?teacher=${teacher}`) // 请求加载课程数据 + .then(response => response.json()) // 解析JSON数据 + .then(data => { + populateSelect(courseSelect, data, "--请选择课程--"); // 填充课程数据 + }) + .catch(error => { + console.error("加载课程失败:", error); // 捕获错误 + }); + } else { + courseSelect.innerHTML = ""; // 清空课程下拉框 + } + } function populateSelect(selectElement, data, placeholder) { selectElement.innerHTML = ""; // 清空下拉框 diff --git a/src/main/webapp/evaluationPage.jsp b/src/main/webapp/evaluationPage.jsp index 2cb059a..80774f6 100644 --- a/src/main/webapp/evaluationPage.jsp +++ b/src/main/webapp/evaluationPage.jsp @@ -64,13 +64,25 @@ 评教页面 -

评教页面

-
- - - +
+

评教页面

+ + + + - <% - for (int i = 0; i < dimensions.length(); i++) { - JSONObject dimension = dimensions.getJSONObject(i); - out.println("
" + dimension.getString("dimension_name") + "(权重:" + dimension.getFloat("weight") + "%)
"); - out.println(""); - out.println(""); - out.println(""); + <% + for (int i = 0; i < dimensions.length(); i++) { + JSONObject dimension = dimensions.getJSONObject(i); + out.println("
" + dimension.getString("dimension_name") + "(权重:" + dimension.getFloat("weight") + "%)
"); + out.println("
题目符合不符合
"); + out.println(""); + out.println(""); - JSONArray questions = dimension.getJSONArray("questions"); - for (int j = 0; j < questions.length(); j++) { - JSONObject question = questions.getJSONObject(j); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); + JSONArray questions = dimension.getJSONArray("questions"); + for (int j = 0; j < questions.length(); j++) { + JSONObject question = questions.getJSONObject(j); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + + out.println("
题目符合不符合
" + question.getString("question_text") + "
" + question.getString("question_text") + "
"); } + %> - out.println(""); - } - %> - - - + + +
\r\n"); - out.write("\r\n"); - out.write("\r\n"); - out.write("
\r\n"); - out.write("

学生评教系统

\r\n"); - out.write("
\r\n"); - out.write("
\r\n"); - out.write(" \r\n"); - out.write(" \r\n"); - out.write("
\r\n"); - out.write("
\r\n"); - out.write(" \r\n"); - out.write(" \r\n"); - out.write("
\r\n"); - out.write("
\r\n"); - out.write(" \r\n"); - out.write(" \r\n"); - out.write("
\r\n"); - out.write(" \r\n"); - out.write("
\r\n"); - out.write("
请选择学院、老师以及课程,然后进入评教页面。
\r\n"); - out.write("
\r\n"); - out.write("\r\n"); - out.write(""); - } catch (java.lang.Throwable t) { - if (!(t instanceof javax.servlet.jsp.SkipPageException)){ - out = _jspx_out; - if (out != null && out.getBufferSize() != 0) - try { - if (response.isCommitted()) { - out.flush(); - } else { - out.clearBuffer(); - } - } catch (java.io.IOException e) {} - if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); - else throw new ServletException(t); - } - } finally { - _jspxFactory.releasePageContext(_jspx_page_context); - } - } -}