From 4cbf294cd902bb53c7ffab22874ea2ab8370d846 Mon Sep 17 00:00:00 2001 From: canglan Date: Thu, 16 Apr 2026 10:08:09 +0800 Subject: [PATCH] =?UTF-8?q?v0.8.3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/homework_service.py | 12 ++++++++++++ frontend/admin/conduct.php | 2 +- frontend/student/dashboard.php | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/services/homework_service.py b/backend/services/homework_service.py index eb57aba..125893e 100644 --- a/backend/services/homework_service.py +++ b/backend/services/homework_service.py @@ -109,11 +109,23 @@ class HomeworkService: # 创建扣分记录 student = await StudentModel.get_by_id(submission["student_id"]) if student: + # 检查分数是否会超出范围(防止溢出) + current_points = student.get("total_points", 0) + new_points = current_points + points_change + if new_points < 0: + return {"success": False, "message": f"分数不能为负(当前{current_points},扣{abs(points_change)})"} + + # 获取操作人姓名 + from models.user import UserModel + user = await UserModel.get_by_user_id(operator_id) + recorder_name = user.get("real_name", "班主任") if user else "班主任" + await ConductModel.create_record( student_id=submission["student_id"], points_change=points_change, reason=f"作业未提交/迟交: {submission['title']}", recorder_id=operator_id, + recorder_name=recorder_name, related_type="homework", related_id=submission["assignment_id"] ) diff --git a/frontend/admin/conduct.php b/frontend/admin/conduct.php index 7c26be5..8c9ed29 100644 --- a/frontend/admin/conduct.php +++ b/frontend/admin/conduct.php @@ -106,7 +106,7 @@ async function exportConductRecords() { showToast('正在导出...', 'info'); try { - const params = { page: 1, page_size: 10000 }; + const params = { page: 1, page_size: 1000 }; if (startDate) params.start_date = startDate; if (endDate) params.end_date = endDate; diff --git a/frontend/student/dashboard.php b/frontend/student/dashboard.php index 2f353ca..67e6d39 100644 --- a/frontend/student/dashboard.php +++ b/frontend/student/dashboard.php @@ -88,6 +88,10 @@ include __DIR__ . '/../includes/header.php';
当前操行分
--
+
+
班级排名
+
--
+
作业完成率
--%
@@ -291,6 +295,18 @@ include __DIR__ . '/../includes/header.php'; document.getElementById('recentRecords').innerHTML = html; } + // 获取班级排名 + const rankingRes = await apiGet('/api/student/ranking', { limit: 100 }); + if (rankingRes && rankingRes.success) { + const ranking = rankingRes.data.ranking || []; + const rank = ranking.find(s => s.student_id === parseInt(STUDENT_ID)); + if (rank) { + document.getElementById('studentRank').textContent = `第${rank.rank}名 / ${ranking.length}人`; + } else { + document.getElementById('studentRank').textContent = '--'; + } + } + // 获取作业统计 const homeworkRes = await apiGet(`/api/student/homework/${STUDENT_ID}`); if (homeworkRes && homeworkRes.success) {