fix(学生管理员): 260 班看板 23 人、数据统计只有 22 人,学生管理员还能看同学的作业代码——学生管理员一律按学生算
Deploy / deploy (push) Canceled after 0s

- 统计、题目页各班表、流程图统计的班级名单原来只认普通用户,改成和看板、排行榜一样的
  STUDENT_ROLES,学生管理员进名单、进分母
- 看别人的提交代码和流程图只给老师、超管和出题人;题单防抄对学生管理员也生效。
  原来「比赛进行中学生管理员不能看」那条特例随之去掉
- 题单的「用户进度」原来只给题单创建者,其余老师点开报「题单不存在」;改成所有老师都能看,
  和看板、统计对所有班开放一致。后台能改能删的接口仍只给创建者

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-08 14:00:11 +08:00
1 parent 30f34f0e36
commit af2ca31de5
6 files changed
+52 -47

No files matched your search

+13 -7
View File
@@ -8,6 +8,7 @@
import {
NO_CLASS,
STUDENT_ROLES,
type ProblemLanguage,
type SubmissionLessons,
type SubmissionStatistics,
@@ -388,8 +389,8 @@ submissionStatisticsRoutes.get("/submissions/statistics", requireTeacher, async
filters.push(matchedIds.length ? inArray(schema.submission.userId, matchedIds) : sql`false`)
}
const where = and(...filters)
// 花名册:只有未禁用的普通用户算进班级人数和「谁没做」,教师和管理员不进分母
const enrolled = matched.filter((row) => !row.isDisabled && row.adminType === "Regular User")
// 花名册:只有未禁用的学生(含学生管理员)算进班级人数和「谁没做」,老师不进分母
const enrolled = matched.filter((row) => !row.isDisabled && STUDENT_ROLES.includes(row.adminType))
const acceptedFilter = sql`count(*) filter (where ${inArray(schema.submission.result, ACCEPTED_RESULTS)})`
// 判题中的条数。要单独数出来,正确率的分母才能把它们摘掉
@@ -524,7 +525,8 @@ submissionStatisticsRoutes.get("/submissions/statistics", requireTeacher, async
const rosterIds = new Set(rosterRows.map((row) => row.id))
const attemptedRows = perUser.filter((row) => {
if (isDone(row)) return false
return scoped ? rosterIds.has(row.userId) : !row.isDisabled && row.adminType === "Regular User"
if (scoped) return rosterIds.has(row.userId)
return !row.isDisabled && row.adminType !== null && STUDENT_ROLES.includes(row.adminType)
})
const dataAttempted = attemptedRows.map((row) => ({
username: row.username,
@@ -587,10 +589,14 @@ submissionStatisticsRoutes.get("/submissions/statistics/grid", requireTeacher, a
className: schema.user.className,
})
.from(schema.submission)
// 只要普通学生:老师试题的提交不该出现在「谁做了几次」里
// 只要学生(含学生管理员):老师试题的提交不该出现在「谁做了几次」里
.innerJoin(schema.user, eq(schema.user.id, schema.submission.userId))
.where(
and(...filters, eq(schema.user.adminType, "Regular User"), eq(schema.user.isDisabled, false)),
and(
...filters,
inArray(schema.user.adminType, [...STUDENT_ROLES]),
eq(schema.user.isDisabled, false),
),
)
.orderBy(desc(schema.submission.createTime))
.limit(GRID_LIMIT + 1)
@@ -672,7 +678,7 @@ submissionStatisticsRoutes.get("/submissions/statistics/grid", requireTeacher, a
.where(
and(
inArray(schema.user.className, names as string[]),
eq(schema.user.adminType, "Regular User"),
inArray(schema.user.adminType, [...STUDENT_ROLES]),
eq(schema.user.isDisabled, false),
),
)
@@ -892,7 +898,7 @@ submissionStatisticsRoutes.get("/submissions/statistics/lessons", requireTeacher
.where(
and(
inArray(schema.user.className, lessonClasses),
eq(schema.user.adminType, "Regular User"),
inArray(schema.user.adminType, [...STUDENT_ROLES]),
eq(schema.user.isDisabled, false),
),
)