v0.8.3测试

This commit is contained in:
2026-04-16 10:08:09 +08:00
parent a33270be0e
commit 4cbf294cd9
3 changed files with 29 additions and 1 deletions

View File

@@ -109,11 +109,23 @@ class HomeworkService:
# 创建扣分记录 # 创建扣分记录
student = await StudentModel.get_by_id(submission["student_id"]) student = await StudentModel.get_by_id(submission["student_id"])
if student: 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( await ConductModel.create_record(
student_id=submission["student_id"], student_id=submission["student_id"],
points_change=points_change, points_change=points_change,
reason=f"作业未提交/迟交: {submission['title']}", reason=f"作业未提交/迟交: {submission['title']}",
recorder_id=operator_id, recorder_id=operator_id,
recorder_name=recorder_name,
related_type="homework", related_type="homework",
related_id=submission["assignment_id"] related_id=submission["assignment_id"]
) )

View File

@@ -106,7 +106,7 @@ async function exportConductRecords() {
showToast('正在导出...', 'info'); showToast('正在导出...', 'info');
try { try {
const params = { page: 1, page_size: 10000 }; const params = { page: 1, page_size: 1000 };
if (startDate) params.start_date = startDate; if (startDate) params.start_date = startDate;
if (endDate) params.end_date = endDate; if (endDate) params.end_date = endDate;

View File

@@ -88,6 +88,10 @@ include __DIR__ . '/../includes/header.php';
<div class="stat-label">当前操行分</div> <div class="stat-label">当前操行分</div>
<div class="stat-value" id="totalPoints">--</div> <div class="stat-value" id="totalPoints">--</div>
</div> </div>
<div class="stat-card">
<div class="stat-label">班级排名</div>
<div class="stat-value" id="studentRank">--</div>
</div>
<div class="stat-card"> <div class="stat-card">
<div class="stat-label">作业完成率</div> <div class="stat-label">作业完成率</div>
<div class="stat-value" id="homeworkRate">--%</div> <div class="stat-value" id="homeworkRate">--%</div>
@@ -291,6 +295,18 @@ include __DIR__ . '/../includes/header.php';
document.getElementById('recentRecords').innerHTML = html; 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}`); const homeworkRes = await apiGet(`/api/student/homework/${STUDENT_ID}`);
if (homeworkRes && homeworkRes.success) { if (homeworkRes && homeworkRes.success) {