diff --git a/backend/controllers/studentController.js b/backend/controllers/studentController.js index 9b741b3..ac4f2e9 100644 --- a/backend/controllers/studentController.js +++ b/backend/controllers/studentController.js @@ -60,4 +60,4 @@ class StudentController { } } -module.exports = StudentController; \ No newline at end of file +module.exports = StudentController; diff --git a/backend/models/Course.js b/backend/models/Course.js index de374a6..9dea61f 100644 --- a/backend/models/Course.js +++ b/backend/models/Course.js @@ -39,4 +39,4 @@ class Course { } } -module.exports = Course; \ No newline at end of file +module.exports = Course; diff --git a/backend/services/studentService.js b/backend/services/studentService.js index 62f7102..32da19a 100644 --- a/backend/services/studentService.js +++ b/backend/services/studentService.js @@ -1,6 +1,5 @@ const Score = require('../models/Score'); const Student = require('../models/Student'); - const Course = require('../models/Course'); class StudentService { @@ -23,10 +22,6 @@ class StudentService { } static async getStudentGrades(userId) { - // 先通过 userId 获取 studentId - // 假设 users.id = students.id,或者通过 user_id 关联 - // 根据之前的 authService,我们假设 users.id 就是 students.id - // 确认学生是否存在 const student = await Student.findById(userId); if (!student) { @@ -72,4 +67,4 @@ class StudentService { } } -module.exports = StudentService; \ No newline at end of file +module.exports = StudentService; diff --git a/database/backup_2025-12-21T14-30-37-825Z.sql b/database/backup_2025-12-21T14-30-37-825Z.sql index 4dd7142..903f9b8 100644 --- a/database/backup_2025-12-21T14-30-37-825Z.sql +++ b/database/backup_2025-12-21T14-30-37-825Z.sql @@ -17,10 +17,10 @@ CREATE TABLE `classes` ( -- Dumping data for table `classes` INSERT INTO `classes` VALUES -(1, '计算机2301', '2023', '计算机科学与技术', 2001, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(2, '软件工程2302', '2023', '软件工程', 2002, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'); - +(1, '计算机2301', '2023', '计算机科学与技术', 2001, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(2, '软件工程2302', '2023', '软件工程', 2002, '2025-12-21 14:23:14', '2025-12-21 14:23:14'); +0 -- Table structure for table `courses` DROP TABLE IF EXISTS `courses`; CREATE TABLE `courses` ( @@ -43,9 +43,9 @@ CREATE TABLE `courses` ( -- Dumping data for table `courses` INSERT INTO `courses` VALUES -(1, 'CS101', '高级程序设计', '4.0', 2001, 1, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(2, 'SE201', '软件工程导论', '3.0', 2002, 2, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(3, 'MAT101', '高等数学', '5.0', 2003, 1, NULL, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'); +(1, 'CS101', '高级程序设计', '4.0', 2001, 1, NULL, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(2, 'SE201', '软件工程导论', '3.0', 2002, 2, NULL, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(3, 'MAT101', '高等数学', '5.0', 2003, 1, NULL, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'); -- Table structure for table `grades` @@ -74,10 +74,10 @@ CREATE TABLE `grades` ( -- Dumping data for table `grades` INSERT INTO `grades` VALUES -(1, 3001, 1, '90.00', '85.00', '88.00', '87.70', '3.00', NULL, 2001, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(2, 3001, 3, '80.00', '75.00', '82.00', '79.30', '2.00', NULL, 2003, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(3, 3002, 1, '95.00', '92.00', '94.00', '93.70', '4.00', NULL, 2001, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'), -(4, 3003, 2, '88.00', '80.00', '85.00', '84.40', '3.00', NULL, 2002, NULL, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'); +(1, 3001, 1, '90.00', '85.00', '88.00', '87.70', '3.00', NULL, 2001, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(2, 3001, 3, '80.00', '75.00', '82.00', '79.30', '2.00', NULL, 2003, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(3, 3002, 1, '95.00', '92.00', '94.00', '93.70', '4.00', NULL, 2001, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'), +(4, 3003, 2, '88.00', '80.00', '85.00', '84.40', '3.00', NULL, 2002, NULL, '2025-12-21 14:23:14', '2025-12-21 14:23:14'); -- Table structure for table `operation_logs` diff --git a/frontend/public/js/student.js b/frontend/public/js/student.js index fabfae7..32b924c 100644 --- a/frontend/public/js/student.js +++ b/frontend/public/js/student.js @@ -12,6 +12,12 @@ class StudentManager { this.initMyCourses(); this.updateCurrentTime(); setInterval(() => this.updateCurrentTime(), 1000); + + // 绑定刷新按钮 + const refreshBtn = document.getElementById('refreshCourses'); + if (refreshBtn) { + refreshBtn.addEventListener('click', () => this.initMyCourses()); + } } updateCurrentTime() { @@ -240,4 +246,4 @@ document.addEventListener('DOMContentLoaded', () => { if (studentClassEl) studentClassEl.textContent = user.class || '未分配'; } }); -}); \ No newline at end of file +}); diff --git a/frontend/views/student/dashboard.html b/frontend/views/student/dashboard.html index c28537a..fbbacbb 100644 --- a/frontend/views/student/dashboard.html +++ b/frontend/views/student/dashboard.html @@ -337,6 +337,39 @@ + +
+
+
我的课程
+ +
+
+ + + + + + + + + + + + + + + + + +
课程代码课程名称学分授课教师学期操作
+
+ 数据加载中... +
+
+
+