From e3e6db2d9974588f91ac1567a58fa4846655ce1b Mon Sep 17 00:00:00 2001
From: yearning <10538594+wangweifeng1999@user.noreply.gitee.com>
Date: 星期三, 30 九月 2026 12:54:55 +0800
Subject: [PATCH] 1.判断题优化;2.新增考评员是否能查看考生隐私开关
---
backend/app/routers/scores_router.py | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/backend/app/routers/scores_router.py b/backend/app/routers/scores_router.py
index e3cff3a..969dea2 100644
--- a/backend/app/routers/scores_router.py
+++ b/backend/app/routers/scores_router.py
@@ -5,6 +5,7 @@
from app.auth import get_current_user
from app.database import get_db
from app.grader_scope import allowed_subjects_for_user, apply_subject_scope
+from app.student_no import ensure_student_no
from app.models import (
ExamPaperMap,
ExaminationExamExaminee,
@@ -14,6 +15,7 @@
User,
)
from app.schemas import ScoreRow, ScoresResponse
+from app.system_settings import get_or_create_settings
router = APIRouter(prefix="/api", tags=["scores"])
@@ -43,12 +45,17 @@
allowed = allowed_subjects_for_user(db, user)
if subject and allowed is not None and subject not in allowed:
raise HTTPException(403, detail="鏃犳潈鏌ョ湅璇ョ鐩�")
+
+ settings = get_or_create_settings(db)
+ hide_privacy = user.role == "grader" and not settings.grader_can_see_privacy
+
q = (
select(
ExaminationExamExaminee,
ExaminationExaminee,
ImportBatch.subject_name,
ExaminationPaperSource.paper_name,
+ ExaminationPaperSource.id,
)
.join(ExaminationExaminee, ExaminationExaminee.id == ExaminationExamExaminee.examinee_id)
.join(ImportBatch, ImportBatch.id == ExaminationExamExaminee.import_batch_id)
@@ -58,10 +65,11 @@
ExaminationPaperSource.id == ExamPaperMap.paper_source_id,
)
)
- if name:
- q = q.where(ExaminationExaminee.nickname.contains(name))
- if id_card:
- q = q.where(ExaminationExaminee.id_card.contains(id_card))
+ if not hide_privacy:
+ if name:
+ q = q.where(ExaminationExaminee.nickname.contains(name))
+ if id_card:
+ q = q.where(ExaminationExaminee.id_card.contains(id_card))
if subject:
q = q.where(ImportBatch.subject_name == subject)
q = apply_subject_scope(q, ImportBatch.subject_name, allowed)
@@ -77,8 +85,9 @@
items = [
ScoreRow(
examinee_id=str(ex.examinee_id),
- name=ee.nickname,
- id_card=ee.id_card,
+ student_no=ensure_student_no(db, ex),
+ name=None if hide_privacy else ee.nickname,
+ id_card=None if hide_privacy else ee.id_card,
subject_name=sn,
score=ex.score,
attempt_id=str(ex.id),
@@ -87,6 +96,6 @@
start_time=ex.start_time,
end_time=ex.end_time,
)
- for ex, ee, sn, pn in rows
+ for ex, ee, sn, pn, ps_id in rows
]
return ScoresResponse(total=total, page=page, page_size=page_size, items=items)
--
Gitblit v1.8.0