Resolve merge conflicts and fix student course details functionality

This commit is contained in:
祀梦
2025-12-22 19:56:36 +08:00
6 changed files with 53 additions and 19 deletions

View File

@@ -1,6 +1,5 @@
const Score = require('../models/Score'); const Score = require('../models/Score');
const Student = require('../models/Student'); const Student = require('../models/Student');
const Course = require('../models/Course'); const Course = require('../models/Course');
class StudentService { class StudentService {
@@ -23,10 +22,6 @@ class StudentService {
} }
static async getStudentGrades(userId) { static async getStudentGrades(userId) {
// 先通过 userId 获取 studentId
// 假设 users.id = students.id或者通过 user_id 关联
// 根据之前的 authService我们假设 users.id 就是 students.id
// 确认学生是否存在 // 确认学生是否存在
const student = await Student.findById(userId); const student = await Student.findById(userId);
if (!student) { if (!student) {

View File

@@ -17,10 +17,10 @@ CREATE TABLE `classes` (
-- Dumping data for table `classes` -- Dumping data for table `classes`
INSERT INTO `classes` VALUES 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 (中国标准时间)'), (1, '计算机2301', '2023', '计算机科学与技术', 2001, '2025-12-21 14:23:14', '2025-12-21 14:23:14'),
(2, '软件工程2302', '2023', '软件工程', 2002, 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)', 'Sun Dec 21 2025 14:23:14 GMT+0800 (中国标准时间)'); (2, '软件工程2302', '2023', '软件工程', 2002, '2025-12-21 14:23:14', '2025-12-21 14:23:14');
0
-- Table structure for table `courses` -- Table structure for table `courses`
DROP TABLE IF EXISTS `courses`; DROP TABLE IF EXISTS `courses`;
CREATE TABLE `courses` ( CREATE TABLE `courses` (
@@ -43,9 +43,9 @@ CREATE TABLE `courses` (
-- Dumping data for table `courses` -- Dumping data for table `courses`
INSERT INTO `courses` VALUES 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 (中国标准时间)'), (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, '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, '2025-12-21 14:23:14', '2025-12-21 14:23:14'),
(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 (中国标准时间)'); (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` -- Table structure for table `grades`
@@ -74,10 +74,10 @@ CREATE TABLE `grades` (
-- Dumping data for table `grades` -- Dumping data for table `grades`
INSERT INTO `grades` VALUES 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 (中国标准时间)'), (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, '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, '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, '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, '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, '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, '2025-12-21 14:23:14', '2025-12-21 14:23:14');
-- Table structure for table `operation_logs` -- Table structure for table `operation_logs`

View File

@@ -12,6 +12,12 @@ class StudentManager {
this.initMyCourses(); this.initMyCourses();
this.updateCurrentTime(); this.updateCurrentTime();
setInterval(() => this.updateCurrentTime(), 1000); setInterval(() => this.updateCurrentTime(), 1000);
// 绑定刷新按钮
const refreshBtn = document.getElementById('refreshCourses');
if (refreshBtn) {
refreshBtn.addEventListener('click', () => this.initMyCourses());
}
} }
updateCurrentTime() { updateCurrentTime() {

View File

@@ -337,6 +337,39 @@
</div> </div>
</div> </div>
<!-- 我的课程表格 -->
<div class="card card-table mb-4" id="courses-section">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0 fw-bold"><i class="fas fa-book me-2 text-primary"></i>我的课程</h5>
<button class="btn btn-sm btn-outline-primary px-3" id="refreshCourses">
<i class="fas fa-sync-alt me-1"></i> 刷新
</button>
</div>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead>
<tr>
<th>课程代码</th>
<th>课程名称</th>
<th>学分</th>
<th>授课教师</th>
<th>学期</th>
<th>操作</th>
</tr>
</thead>
<tbody id="coursesTableBody">
<!-- 数据将由 JavaScript 填充 -->
<tr>
<td colspan="6" class="text-center py-5 text-muted">
<div class="spinner-border spinner-border-sm me-2" role="status"></div>
数据加载中...
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 成绩表格 --> <!-- 成绩表格 -->
<div class="card card-table" id="grades-section"> <div class="card card-table" id="grades-section">
<div class="card-header d-flex justify-content-between align-items-center"> <div class="card-header d-flex justify-content-between align-items-center">