This commit is contained in:
sishenjieshuo 2025-02-15 14:30:24 +08:00
parent 2e22b9c5c0
commit 5968f89d03
13 changed files with 150 additions and 385 deletions

View File

@ -1,41 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4"> <module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
</configuration>
</facet>
<facet type="web" name="Web3">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/conf/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/conf" relative="/WEB-INF" />
</webroots>
</configuration>
</facet>
<facet type="web" name="Web2">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/.smarttomcat/School-ST/conf/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/.smarttomcat/School-ST/conf" relative="/WEB-INF" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="lib" level="project" />
</component> </component>
</module> </module>

18
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost" uuid="2408be1d-a4a6-4f58-a340-9858f08d618b">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

9
.idea/libraries/lib.xml Normal file
View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="lib" type="kotlin.js">
<CLASSES>
<root url="file://$PROJECT_DIR$/src/main/webapp/WEB-INF/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

13
.idea/webContexts.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebContextManager">
<option name="state">
<map>
<entry key="file://$PROJECT_DIR$/src/main/webapp/admin.jsp" value="file://$PROJECT_DIR$/src/main/webapp" />
<entry key="file://$PROJECT_DIR$/src/main/webapp/evaluationPage.jsp" value="file://$PROJECT_DIR$/src/main/webapp" />
<entry key="file://$PROJECT_DIR$/src/main/webapp/loadCourses.jsp" value="file://$PROJECT_DIR$/src/main/webapp" />
<entry key="file://$PROJECT_DIR$/src/main/webapp/loadTeachers.jsp" value="file://$PROJECT_DIR$/src/main/webapp" />
</map>
</option>
</component>
</project>

View File

@ -1,2 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Context docBase="D:\Jetbrains\Coding\Idea\SchoolST\src\main\webapp"/> <Context docBase="F:\Coding\JetBrains\Idea\KTT\School-ST\src\main\webapp">
<Resources cacheMaxSize="10240">
<PreResources base="F:/Coding/JetBrains/Idea/KTT/School-ST/src/main/webapp/WEB-INF/lib" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes"/>
</Resources>
</Context>

View File

@ -51,14 +51,20 @@
<th>平均得分</th> <th>平均得分</th>
</tr> </tr>
<% <%
try {//加载数据库驱动 try {
Class.forName("com.mysql.cj.jdbc.Driver");//连接数据库 Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");//查询语句 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对象 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();//执行查询 Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);//遍历结果集 ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {//输出结果 //老师姓名 //平均得分 while (rs.next()) {
out.println("<tr><td>" + rs.getString("name") + "</td><td>" + rs.getDouble("avg_score") + "</td></tr>");//关闭连接 // 使用 JSP 表达式输出内容
%>
<tr>
<td><%= rs.getString("name") %></td>
<td><%= rs.getDouble("avg_score") %></td>
</tr>
<%
} }
rs.close(); rs.close();
stmt.close(); stmt.close();
@ -70,4 +76,4 @@
</table> </table>
</div> </div>
</body> </body>
</html> </html>

View File

@ -23,7 +23,7 @@
border-radius: 10px; /* 圆角 */ border-radius: 10px; /* 圆角 */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影 */ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影 */
text-align: center; /* 文本居中对齐 */ text-align: center; /* 文本居中对齐 */
} }vv
/* 表单样式 */ /* 表单样式 */
.form-group { .form-group {
margin-bottom: 15px; /* 表单组之间的间距 */ margin-bottom: 15px; /* 表单组之间的间距 */
@ -112,6 +112,22 @@
courseSelect.innerHTML = "<option value=''>--请选择课程--</option>"; // 清空课程下拉框 courseSelect.innerHTML = "<option value=''>--请选择课程--</option>"; // 清空课程下拉框
} }
} }
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 = "<option value=''>--请选择课程--</option>"; // 清空课程下拉框
}
}
function populateSelect(selectElement, data, placeholder) { function populateSelect(selectElement, data, placeholder) {
selectElement.innerHTML = ""; // 清空下拉框 selectElement.innerHTML = ""; // 清空下拉框

View File

@ -64,13 +64,25 @@
<head> <head>
<title>评教页面</title> <title>评教页面</title>
<style> <style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
color: #333;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
margin-bottom: 20px; margin-bottom: 20px;
background-color: #fff;
box-shadow: 0 2px 3px rgba(0,0,0,0.1);
} }
th, td { th, td {
padding: 10px; padding: 12px;
border: 1px solid #ddd; border: 1px solid #ddd;
text-align: left; text-align: left;
} }
@ -82,43 +94,64 @@
font-weight: bold; font-weight: bold;
margin-top: 20px; margin-top: 20px;
margin-bottom: 10px; margin-bottom: 10px;
color: #333;
} }
.question-text { .question-text {
font-weight: normal; font-weight: normal;
} }
.form-container {
max-width: 800px;
margin: 0 auto;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
</style> </style>
</head> </head>
<body> <body>
<h1>评教页面</h1> <div class="form-container">
<form action="submitEvaluation.jsp" method="post" onsubmit="return validateForm()"> <h1>评教页面</h1>
<input type="hidden" name="college" value="<%= college %>"> <form action="submitEvaluation.jsp" method="post" onsubmit="return validateForm()">
<input type="hidden" name="teacher" value="<%= teacher %>"> <input type="hidden" name="college" value="<%= college %>">
<input type="hidden" name="course" value="<%= course %>"> <input type="hidden" name="teacher" value="<%= teacher %>">
<input type="hidden" name="course" value="<%= course %>">
<% <%
for (int i = 0; i < dimensions.length(); i++) { for (int i = 0; i < dimensions.length(); i++) {
JSONObject dimension = dimensions.getJSONObject(i); JSONObject dimension = dimensions.getJSONObject(i);
out.println("<div class='dimension-title'>" + dimension.getString("dimension_name") + "(权重:" + dimension.getFloat("weight") + "%</div>"); out.println("<div class='dimension-title'>" + dimension.getString("dimension_name") + "(权重:" + dimension.getFloat("weight") + "%</div>");
out.println("<table>"); out.println("<table>");
out.println("<thead><tr><th>题目</th><th>符合</th><th>不符合</th></tr></thead>"); out.println("<thead><tr><th>题目</th><th>符合</th><th>不符合</th></tr></thead>");
out.println("<tbody>"); out.println("<tbody>");
JSONArray questions = dimension.getJSONArray("questions"); JSONArray questions = dimension.getJSONArray("questions");
for (int j = 0; j < questions.length(); j++) { for (int j = 0; j < questions.length(); j++) {
JSONObject question = questions.getJSONObject(j); JSONObject question = questions.getJSONObject(j);
out.println("<tr>"); out.println("<tr>");
out.println("<td class='question-text'>" + question.getString("question_text") + "</td>"); out.println("<td class='question-text'>" + question.getString("question_text") + "</td>");
out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='1' required></td>"); out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='1' required></td>");
out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='0' required></td>"); out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='0' required></td>");
out.println("</tr>"); out.println("</tr>");
}
out.println("</tbody></table>");
} }
%>
out.println("</tbody></table>"); <button type="submit">提交评价</button>
} </form>
%> </div>
<button type="submit">提交评价</button>
</form>
<script> <script>
const totalQuestionCount = <%= totalQuestionCount %>; const totalQuestionCount = <%= totalQuestionCount %>;

View File

@ -69,4 +69,4 @@
e.printStackTrace(); e.printStackTrace();
out.println("数据库表初始化失败:" + e.getMessage()); out.println("数据库表初始化失败:" + e.getMessage());
} }
%> %>

View File

@ -7,22 +7,19 @@
if (teacherId != null && !teacherId.isEmpty()) { if (teacherId != null && !teacherId.isEmpty()) {
try { try {
Class.forName("com.mysql.cj.jdbc.Driver"); Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
String sql = "SELECT * FROM courses WHERE teacher_id = ?"; String sql = "SELECT * FROM courses WHERE teacher_id = ?";
PreparedStatement pstmt = conn.prepareStatement(sql); try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
pstmt.setString(1, teacherId); PreparedStatement pstmt = conn.prepareStatement(sql)) {
ResultSet rs = pstmt.executeQuery(); pstmt.setString(1, teacherId);
try (ResultSet rs = pstmt.executeQuery()) {
while (rs.next()) { while (rs.next()) {
JSONObject course = new JSONObject(); JSONObject course = new JSONObject();
course.put("course_id", rs.getInt("course_id")); course.put("course_id", rs.getInt("course_id"));
course.put("course_name", rs.getString("course_name")); course.put("course_name", rs.getString("course_name"));
courses.put(course); courses.put(course);
}
}
} }
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

Binary file not shown.

View File

@ -1,300 +0,0 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.99
* Generated at: 2025-02-12 08:16:08 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class evaluate_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.LinkedHashSet<>(4);
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = null;
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS");
return;
}
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write(" <title>学生评教系统</title>\r\n");
out.write(" <style>\r\n");
out.write(" /* 全局样式 */\r\n");
out.write(" body {\r\n");
out.write(" font-family: Arial, sans-serif; /* 设置字体 */\r\n");
out.write(" background-color: #f0f2f5; /* 设置背景颜色 */\r\n");
out.write(" margin: 0; /* 移除默认外边距 */\r\n");
out.write(" padding: 20px; /* 设置内边距 */\r\n");
out.write(" }\r\n");
out.write(" h1 {\r\n");
out.write(" text-align: center; /* 标题居中 */\r\n");
out.write(" color: #2c3e50; /* 标题颜色 */\r\n");
out.write(" }\r\n");
out.write(" .container {\r\n");
out.write(" max-width: 800px; /* 设置容器最大宽度 */\r\n");
out.write(" margin: 0 auto; /* 居中对齐 */\r\n");
out.write(" background: white; /* 背景颜色 */\r\n");
out.write(" padding: 20px; /* 内边距 */\r\n");
out.write(" border-radius: 10px; /* 圆角 */\r\n");
out.write(" box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影 */\r\n");
out.write(" text-align: center; /* 文本居中对齐 */\r\n");
out.write(" }\r\n");
out.write(" /* 表单样式 */\r\n");
out.write(" .form-group {\r\n");
out.write(" margin-bottom: 15px; /* 表单组之间的间距 */\r\n");
out.write(" text-align: center; /* 表单组内容居中对齐 */\r\n");
out.write(" }\r\n");
out.write(" form {\r\n");
out.write(" display: flex; /* 使用弹性布局 */\r\n");
out.write(" flex-direction: column; /* 垂直排列 */\r\n");
out.write(" gap: 15px; /* 表单元素间距 */\r\n");
out.write(" align-items: center; /* 垂直居中对齐 */\r\n");
out.write(" }\r\n");
out.write(" label {\r\n");
out.write(" font-weight: bold; /* 加粗标签文本 */\r\n");
out.write(" color: #34495e; /* 标签颜色 */\r\n");
out.write(" margin-bottom: 5px; /* 标签与下拉框之间的间距 */\r\n");
out.write(" }\r\n");
out.write(" select {\r\n");
out.write(" padding: 8px; /* 内边距 */\r\n");
out.write(" border: 1px solid #bdc3c7; /* 边框样式 */\r\n");
out.write(" border-radius: 4px; /* 圆角 */\r\n");
out.write(" outline: none; /* 取消默认焦点样式 */\r\n");
out.write(" appearance: none; /* 取消默认箭头样式 */\r\n");
out.write(" background-color: white; /* 背景颜色 */\r\n");
out.write(" background-image: url('<url id=\"cum5gspic4u9hucljb80\" type=\"url\" status=\"failed\" title=\"\" wc=\"0\">https://cdn.jsdelivr.net/gh/a854451261/cdn/icon/select-arrow.svg</url> '); /* 自定义箭头样式 */\r\n");
out.write(" background-repeat: no-repeat; /* 背景图片不重复 */\r\n");
out.write(" background-position: right 8px center; /* 背景图片位置 */\r\n");
out.write(" background-size: 12px 8px; /* 背景图片大小 */\r\n");
out.write(" text-align: center; /* 文本居中对齐 */\r\n");
out.write(" cursor: pointer; /* 鼠标悬停时显示手指图标 */\r\n");
out.write(" width: calc(100% - 16px); /* 宽度自适应 */\r\n");
out.write(" }\r\n");
out.write(" button {\r\n");
out.write(" background: linear-gradient(#3498db, #2980b9); /* 按钮渐变背景 */\r\n");
out.write(" color: white; /* 文本颜色 */\r\n");
out.write(" padding: 10px 20px; /* 内边距 */\r\n");
out.write(" border: none; /* 移除边框 */\r\n");
out.write(" border-radius: 5px; /* 圆角 */\r\n");
out.write(" cursor: pointer; /* 鼠标悬停时显示手指图标 */\r\n");
out.write(" transition: background 0.3s; /* 背景过渡效果 */\r\n");
out.write(" box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影 */\r\n");
out.write(" }\r\n");
out.write(" button:hover {\r\n");
out.write(" background: linear-gradient(#2980b9, #3498db); /* 鼠标悬停时的渐变背景 */\r\n");
out.write(" }\r\n");
out.write(" /* 提示语 */\r\n");
out.write(" .hint {\r\n");
out.write(" color: #7f8c8d; /* 提示文本颜色 */\r\n");
out.write(" font-size: 0.9em; /* 字体大小 */\r\n");
out.write(" margin-top: 10px; /* 提示与表单之间的间距 */\r\n");
out.write(" }\r\n");
out.write(" </style>\r\n");
out.write(" <script>\r\n");
out.write(" // 动态加载老师和课程\r\n");
out.write(" function loadTeachers(college) {\r\n");
out.write(" const teachersSelect = document.getElementById(\"teacher\"); // 获取老师下拉框\r\n");
out.write(" const courseSelect = document.getElementById(\"course\"); // 获取课程下拉框\r\n");
out.write("\r\n");
out.write(" if (college) {\r\n");
out.write(" fetch(`loadTeachers.jsp?college=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${college}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write("`) // 请求加载老师数据\r\n");
out.write(" .then(response => response.json()) // 解析JSON数据\r\n");
out.write(" .then(data => {\r\n");
out.write(" populateSelect(teachersSelect, data, \"--请选择老师--\"); // 填充老师数据\r\n");
out.write(" })\r\n");
out.write(" .catch(error => {\r\n");
out.write(" console.error(\"加载老师失败:\", error); // 捕获错误\r\n");
out.write(" });\r\n");
out.write(" } else {\r\n");
out.write(" teachersSelect.innerHTML = \"<option value=''>--请选择老师--</option>\"; // 清空老师下拉框\r\n");
out.write(" courseSelect.innerHTML = \"<option value=''>--请选择课程--</option>\"; // 清空课程下拉框\r\n");
out.write(" }\r\n");
out.write(" }\r\n");
out.write("\r\n");
out.write(" function loadCourses(teacher) {\r\n");
out.write(" const courseSelect = document.getElementById(\"course\"); // 获取课程下拉框\r\n");
out.write("\r\n");
out.write(" if (teacher) {\r\n");
out.write(" fetch(`loadCourses.jsp?teacher=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${teacher}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write("`) // 请求加载课程数据\r\n");
out.write(" .then(response => response.json()) // 解析JSON数据\r\n");
out.write(" .then(data => {\r\n");
out.write(" populateSelect(courseSelect, data, \"--请选择课程--\"); // 填充课程数据\r\n");
out.write(" })\r\n");
out.write(" .catch(error => {\r\n");
out.write(" console.error(\"加载课程失败:\", error); // 捕获错误\r\n");
out.write(" });\r\n");
out.write(" } else {\r\n");
out.write(" courseSelect.innerHTML = \"<option value=''>--请选择课程--</option>\"; // 清空课程下拉框\r\n");
out.write(" }\r\n");
out.write(" }\r\n");
out.write("\r\n");
out.write(" function populateSelect(selectElement, data, placeholder) {\r\n");
out.write(" selectElement.innerHTML = \"\"; // 清空下拉框\r\n");
out.write(" const defaultOption = document.createElement(\"option\"); // 创建默认选项\r\n");
out.write(" defaultOption.value = \"\"; // 默认选项值\r\n");
out.write(" defaultOption.text = placeholder; // 默认选项文本\r\n");
out.write(" selectElement.appendChild(defaultOption); // 添加默认选项\r\n");
out.write("\r\n");
out.write(" data.forEach(item => { // 遍历并填充数据\r\n");
out.write(" const option = document.createElement(\"option\");\r\n");
out.write(" option.value = item.value || item.course_id; // 设置选项值\r\n");
out.write(" option.text = item.text || item.course_name; // 设置选项文本\r\n");
out.write(" selectElement.appendChild(option); // 添加选项\r\n");
out.write(" });\r\n");
out.write(" }\r\n");
out.write(" </script>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("<div class=\"container\">\r\n");
out.write(" <h1>学生评教系统</h1>\r\n");
out.write(" <form id=\"evaluationForm\" action=\"evaluationPage.jsp\" method=\"get\">\r\n");
out.write(" <div class=\"form-group\">\r\n");
out.write(" <label for=\"college\">选择学院:</label> <!-- 学院标签 -->\r\n");
out.write(" <select id=\"college\" name=\"college\" onchange=\"loadTeachers(this.value)\"> <!-- 学院下拉框 -->\r\n");
out.write(" <option value=\"\">--请选择学院--</option> <!-- 默认选项 -->\r\n");
out.write(" <option value=\"信息工程学院\">信息工程学院</option> <!-- 学院选项 -->\r\n");
out.write(" <option value=\"智能工学院\">智能工学院</option> <!-- 学院选项 -->\r\n");
out.write(" <option value=\"物理学院\">物理学院</option> <!-- 学院选项 -->\r\n");
out.write(" </select>\r\n");
out.write(" </div>\r\n");
out.write(" <div class=\"form-group\">\r\n");
out.write(" <label for=\"teacher\">选择老师:</label> <!-- 老师标签 -->\r\n");
out.write(" <select id=\"teacher\" name=\"teacher\" onchange=\"loadCourses(this.value)\"> <!-- 老师下拉框 -->\r\n");
out.write(" <option value=\"\">--请选择老师--</option> <!-- 默认选项 -->\r\n");
out.write(" </select>\r\n");
out.write(" </div>\r\n");
out.write(" <div class=\"form-group\">\r\n");
out.write(" <label for=\"course\">选择课程:</label> <!-- 课程标签 -->\r\n");
out.write(" <select id=\"course\" name=\"course\"> <!-- 课程下拉框 -->\r\n");
out.write(" <option value=\"\">--请选择课程--</option> <!-- 默认选项 -->\r\n");
out.write(" </select>\r\n");
out.write(" </div>\r\n");
out.write(" <button type=\"submit\">进入评教页面</button> <!-- 提交按钮 -->\r\n");
out.write(" </form>\r\n");
out.write(" <div class=\"hint\">请选择学院、老师以及课程,然后进入评教页面。</div> <!-- 提示语 -->\r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} 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);
}
}
}