Commit Graph

139 Commits

Author SHA1 Message Date
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
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
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
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
65c48437a9 fix 2026-05-24 20:44:02 -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
df097dd610 fix flowchart 2026-05-07 06:09:13 -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
a12a665fde update 2026-03-18 13:26:32 +08:00
3cd944a7e1 fix 2026-03-08 21:37:46 +08:00
6527d8bfe5 update 2026-03-08 21:31:00 +08:00
889380c58e add teaching feature 2026-03-08 21:15:46 +08:00
ed40019a14 自动生成流程图 2026-01-05 10:23:02 +08:00
aa95f171a9 fix 2025-10-23 10:22:22 +08:00
8989ec0406 fix 2025-10-23 10:22:02 +08:00
6465f8fab2 add sort 2025-10-14 21:30:44 +08:00
4168d41a16 删除无用代码并且新增流程图相关内容 2025-10-11 23:29:56 +08:00
cbe0e297fd update acm helper 2025-10-06 00:06:59 +08:00
7835cf013a 后台出题人 2025-10-03 14:30:40 +08:00