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';