38f92ed911
chore: 删 11 个无引用序列化器;撤回一处误判的"修复"
...
## 撤回:增删题单题目本来就会重算进度,我诊断错了
上一个 commit 我给 ProblemSetProblemAdminAPI 的 post/delete 加了显式的
sync_all_progress_for_problemset,理由是"增删题目不重算进度"。**那是错的。**
problemset/signals.py 里有 post_save / post_delete 信号接收器,
在 ProblemSetProblem 变化时同步进度**并重算奖章**,且 apps.py 的 ready()
确实导入了 signals。我的显式调用只是让同一件事做两遍。
更该记住的是**为什么当时没发现**:那一版测试只看"进度有没有更新",
而信号和我的调用都会让它更新 —— 分不出是谁干的,所以照样是绿的。
这次的测试改成先撤掉调用再验,并直接断言信号已注册在 post_save/post_delete 上,
这样才真的有区分力。6/6 通过。
同一批修复里的另外 5 条经复核都成立,保留。特别是「移除用户留下孤儿奖章」——
signals.py 里**没有**针对 ProblemSetProgress 的 post_delete,那条必须自己清。
## 删无引用序列化器(-78 行)
全仓 106 个序列化器,11 个无任何引用:
account: FileUploadForm, GenerateUserSerializer, SSOSerializer,
UserChangeEmailSerializer, UserChangePasswordSerializer,
UsernameOrEmailCheckSerializer
contest: CreateContestAnnouncementSerializer, EditContestAnnouncementSerializer
problem: CreateProblemCodeTemplateSerializer
flowchart: FlowchartSubmissionMergedSerializer, FlowchartSubmissionSummarySerializer
前 8 个是上一个 commit 删掉的视图留下的(FileUploadForm 正是
SimditorFileUploadAPIView 用的),后 3 个是原本就死的。
检测器同样做了自检:拿 3 个明确在用的序列化器反测,没有误判。
另外确认这 11 个都没有字符串形式的动态引用。
`ruff check .` 全绿。行尾未被改动(上一轮踩过这个坑,这次脚本里加了断言)。
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
2026-08-08 07:19:02 -06:00
4ebcecfab4
fix: 修掉重写期间在旧后端发现的 6 个问题
...
这些是做 Bun 重写时逐行对照发现的,旧后端现在还在线上跑,学生今天就在踩。
每条都在本地起 Django + postgres 实跑验证过,**正反两面都验**:越权要挡住、
正常操作要还能用。合计 14 条断言全过。
## 越权(跨教师)
**ACMContestHelper.put** — 只按 pk 取 rank,任何老师都能改**别人比赛**里的
检查标记。而 `contest_id` 明明在 ACMContesHelperSerializer 里、客户端一直在传,
视图完全没用它。改成按 (pk, contest_id) 取 + ensure_created_by。
同类的 get 本来就有 ensure_created_by,是 put 漏了。
**AddContestProblemAPI.post** — 一个权限装饰器都没有,导致两件事:
- 少 problem_permission_required:problem_permission=None 的学生管理员也能建题
- 少 ensure_created_by:任何管理员都能往**别人的比赛**里塞题
另外源题只按 id 取,能把别人比赛里的赛题(或别人未公开的草稿)拷进自己的比赛,
连 answers 参考答案一起拿到。改成源题必须是公开题库题,不可见的要求归属。
(中间件 AdminRoleRequiredMiddleware 只保证"是管理员身份",挡不住这些。)
## 会 500
**ProblemVisibleAPI.put** — `self.error(...)` 漏写 return,题不存在时继续执行到
未赋值的 problem,抛 UnboundLocalError → 500。
## 数据正确性
**ProblemSetAdminAPI.get** — 后台列表写死 filter(visible=True),而列表里就有
可见性开关:一旦关掉,题单从后台消失,教师再也找不到、也无法在界面上打开回来。
后台列表不该过滤 visible,前台该。
**增删题单题目不重算进度** — 题目数是进度的分母。不重算的话学生进度百分比全是
虚高的,原本标"已完成"的人会一直是已完成。更麻烦的是那个手动同步接口
(ProblemSetSyncAPI)前端没有调用点,等于**界面上根本没办法修**。
改成增删之后直接 sync_all_progress_for_problemset。
**移除用户留下孤儿奖章** — 只删了 ProblemSetProgress,UserBadge 还在。学生个人页
会一直挂着一个自己已不在的题单的奖章,而且重新加入时因唯一约束拿不到第二次。
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
2026-08-08 06:50:47 -06:00
3a99c6a890
fix
2026-08-06 08:25:48 -06:00
fbbbe11388
feat: 后台题目列表支持按标签筛选
2026-08-05 06:00:03 -06:00
db104ac091
fix(problem): resolve_tags 的 create 包一层 atomic
...
外层若在事务里,IntegrityError 会中止整个事务,导致回查抛
TransactionManagementError。当前未开 ATOMIC_REQUESTS 所以还没触发,
但仓库多处用了 transaction.atomic(),属于随时会踩的坑。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com >
2026-08-05 04:29:48 -06:00
5b393a3b4c
feat(problem): 新增批量给题目添加/移除标签接口
...
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com >
2026-08-05 04:21:08 -06:00
c775ae4b22
feat(problem): 新增标签管理接口
...
列表带题目数,重命名撞名时自动合并并返回受影响题数,删除后清标签缓存。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com >
2026-08-05 04:18:41 -06:00
ec7cf71ea7
refactor(problem): 标签创建逻辑收敛到 services.resolve_tags
...
原本 4 处题目保存逻辑各自复制了一份 get-or-create,且大小写敏感、有竞态。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com >
2026-08-05 04:15:36 -06:00
f0da3de9c0
feat(problem): 标签名去空格并加大小写不敏感唯一约束
...
迁移时先合并已存在的重复标签,题目关系转移到保留的那个。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com >
2026-08-05 04:07:53 -06:00
224960ac0f
fix
2026-07-26 07:20:16 -06:00
66fac1f66d
update
2026-07-05 03:12:34 -06:00
9535b64a4b
精简 Problem 模型:移除 rule_type / total_score / io_mode
...
系统只用 ACM 模式且题目固定标准 IO,这三列已无实际用途:
- rule_type / total_score:OI 专用,删除后 judge/dispatcher 的 OI 分支全部塌缩为 ACM
- io_mode:判题改为固定发送 Standard IO 常量;languages.py 的 seccomp_rule
保留 dict 形态但改用字面量 key,不改判题机 wire 契约
- prompt 字段保留(预留给未来 AI 分析)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
2026-07-04 11:40:38 -06:00
4743b0398a
update
2026-07-04 11:07:24 -06:00
deae73cd88
feat: SQL 题测试点脚本回显接口
...
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 19:29:51 -06:00
803d6ca58d
feat: SQL 题测试点预览接口
...
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 19:25:47 -06:00
2ec036ac37
feat: 新增 rebuild_sql_display 管理命令,为存量 SQL 题回填展示数据
...
生成逻辑从 ProblemBase._build_sql_display 提取为 problem.utils.generate_sql_display,
管理端保存与回填命令共用。命令支持 --dry-run / --force。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 09:42:11 -06:00
5af9d67fe2
fix: 终审修复——test_case_id 格式校验、modify 空变更报错、异常兜底与文档补充
...
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 06:26:00 -06:00
67079b5304
fix: _build_sql_display 兜底 info 结构损坏,避免 KeyError 导致 500
...
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 01:22:27 -06:00
06642b8131
feat: 保存 SQL 题时自动生成 sql_display 展示数据
...
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-03 01:15:58 -06:00
9f7f818d51
新增 SQL 题型:SQLite 内联判题(不依赖外部沙箱)
...
- SQL 作为语言接入现有提交流程,judge_task 按 language 分流到 SQLJudgeDispatcher
- judge/sql_runner.py:内存 SQLite 判题核心,查询题比结果集/增删改题比表状态,
authorizer + progress_handler + max_page_count 三重防护
- dispatcher 提取 _process_judge_result/_push_status 供 SQL 判题复用(行为不变)
- 测试点通道支持 1.sql..N.sql 压缩包,出题只需数据脚本+标准答案
- Problem 增加 sql_config 字段;options 数据迁移注册 SQL 语言
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
2026-07-02 17:23:13 -06:00
d7e04adf07
fix
2026-06-05 09:46:49 -06:00
809673e64f
fix
2026-06-03 04:50:46 -06:00
d1fdbcf52b
fix
2026-06-02 23:13:06 -06:00
385d04505b
feat: open teaching analytics to Teacher Admin
...
StuckProblems, TopACTrend, AI user analysis, and problemset user
progress are now accessible to Teacher Admin (previously super-only).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-06-02 18:17:26 -06:00
f94d29cf93
feat: add Teacher Admin role to four-tier permission system
...
Introduces a four-tier role system: Regular User → Student Admin →
Teacher Admin → Super Admin. Teacher Admin can manage own contests,
problemsets, and view classroom data. Student Admin (renamed from Admin)
retains problem management only.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-06-02 18:13:33 -06:00
6ab2886f77
remove contest type
2026-05-26 23:10:27 -06:00
48a16d91b5
refactor: replace sync_to_async aggregate with aaggregate in problem views
2026-05-26 21:46:56 -06:00
57c0572fd9
async
2026-05-26 21:25:26 -06:00
1217ee3eaf
update
2026-05-26 02:19:26 -06:00
bf2a95ef01
update
2026-05-25 23:55:19 -06:00
2e7c6fb404
update
2026-05-25 21:56:11 -06:00
980b803517
feat: update all query filters to treat AST_CHECK_FAILED as accepted
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-25 20:45:15 -06:00
c36e6623bd
feat: add AST_CHECK_FAILED status, is_accepted helper, ast_rules field
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-25 20:37:58 -06:00
65c48437a9
fix
2026-05-24 20:44:02 -06:00
8a0bfb6b24
update
2026-05-21 19:52:37 -06:00
a744baf4c9
fix
2026-05-17 07:31:05 -06:00
c9751c095f
update
2026-05-11 04:32:49 -06:00
ee84a0abe3
update
2026-05-11 04:27:15 -06:00
25bd43676e
update
2026-05-11 00:55:01 -06:00
128745f4f8
update yearly ac rate
2026-05-11 00:43:08 -06:00
238adf441f
fix: remove duplicate return statement in ProblemYearlyACRateAPI
2026-05-11 00:19:37 -06:00
74d5c7256d
feat: add problem yearly AC rate API endpoint
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-11 00:19:16 -06:00
e4e8b7759d
update for django6
2026-05-09 05:57:30 -06:00
c466dfd3c6
change enum
2026-05-09 02:30:47 -06:00
df097dd610
fix flowchart
2026-05-07 06:09:13 -06:00
e2d566436f
add index for models
2026-04-23 14:10:48 -06:00
028ea6e5f9
fmt
2026-04-23 13:57:56 -06:00
c4ddfa6841
add flowchart
2026-04-12 06:00:39 -06:00
c31145f76e
fix cache
2026-03-30 09:39:35 -06:00
24ff67ec0c
fix
2026-03-30 09:34:38 -06:00