yuetsh 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
fix
2026-07-26 07:21:56 -06:00
2026-08-05 04:45:26 -06:00
2026-05-26 21:25:26 -06:00
2026-08-05 04:45:26 -06:00
2025-05-10 21:53:57 +08:00
fix
2026-08-06 08:25:48 -06:00
2026-08-05 04:45:26 -06:00
2026-08-05 04:45:26 -06:00
fix
2026-08-06 08:25:48 -06:00
2026-08-05 23:17:48 -06:00
fix
2026-08-06 08:36:01 -06:00
2026-08-05 04:45:26 -06:00
2017-01-24 13:36:28 +08:00
fix
2026-06-14 09:27:21 -06:00
2021-11-18 12:38:49 +08:00
2026-05-26 07:37:05 -06:00
2019-01-05 14:12:14 +08:00
2017-11-30 09:42:16 +08:00
2026-08-05 04:45:26 -06:00
2021-12-18 01:15:03 +08:00
2021-12-18 01:15:03 +08:00
2026-05-05 07:45:23 -06:00

OnlineJudge 2.0

Python Django Django Rest Framework Build Status

An onlinejudge system based on Python and Vue. Demo

中文文档

Overview

  • Based on Docker; One-click deployment
  • Separated backend and frontend; Modular programming; Micro service
  • ACM/OI rule support; realtime/non-realtime rank support
  • Amazing charting and visualization
  • Template-problem support
  • More reasonable permission control
  • Multi-language support: C, C++, Java, Python2, Python3
  • Markdown & MathJax support
  • Contest participants IP limit(CIDR)

Main modules are available below:

Installation

Follow me: https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0

Documents

http://opensource.qduoj.com/

Screenshots

Frontend:

problem-list

problem-details

statistic-info

contest-list

You can control the menu and chart status in rankings.

acm-rankings

oi-rankings

status

status-details

user-home

Admin:

admin-users

judge-server

create-problem

create-contest

Browser Support

Modern browsers(chrome, firefox) and Internet Explorer 10+.

Thanks

  • I'd appreciate a star if you find this helpful.
  • Thanks to everyone that contributes to this project.
  • Special thanks to heb1c, who has given us a lot of suggestions.

License

MIT

Description
No description provided
Readme 12 MiB