Skip to content

Commit e479cb9

Browse files
committed
core&ui: contest correction mode
1 parent a921569 commit e479cb9

10 files changed

Lines changed: 56 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ Hydro 用户群:1085853538
143143
- framework: 添加 Subscription API
144144
- core: 添加 fixStorage 脚本
145145
- core: websocket: 重构 Subscription API
146-
- ui: 允许跨页选择题目
146+
- ui: 允许跨页选择题目,支持批量选择题目
147147
- judge: 重构 config.detail 设置
148148
- core: 自动清理多余的静态文件
149149
- ui: 优化比赛题目列表显示
150-
150+
- core: 添加补题模式
151151

152152
### Bug Fixes
153153

packages/hydrooj/src/handler/contest.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,18 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler {
207207
const psdocs: any[] = Object.values(this.response.body.psdict);
208208
const canViewRecord = contest.canShowSelfRecord.call(this, this.tdoc);
209209
this.response.body.canViewRecord = canViewRecord;
210+
const rids = psdocs.map((i) => i.rid);
211+
if (contest.isDone(this.tdoc) && canViewRecord) {
212+
const correction = await problem.getListStatus(domainId, this.user._id, this.tdoc.pids);
213+
for (const pid in correction) {
214+
if (this.tsdoc.detail[pid]?.rid === correction[pid].rid) delete correction[pid];
215+
}
216+
rids.push(...Object.values(correction).map((i) => i.rid));
217+
this.response.body.correction = correction;
218+
}
210219
[this.response.body.rdict, this.response.body.rdocs] = canViewRecord
211220
? await Promise.all([
212-
record.getList(domainId, psdocs.map((i: any) => i.rid)),
221+
record.getList(domainId, rids),
213222
record.getMulti(domainId, { contest: tid, uid: this.user._id })
214223
.sort({ _id: -1 }).toArray(),
215224
])

packages/hydrooj/src/handler/problem.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
334334
discussionCount: dcnt,
335335
tdoc: this.tdoc,
336336
owner_udoc: (tid && this.tdoc.owner !== this.pdoc.owner) ? await user.getById(domainId, this.tdoc.owner) : null,
337+
mode: !tid ? 'normal'
338+
: !this.tsdoc?.attend ? 'view'
339+
: !contest.isDone(this.tdoc) ? 'contest'
340+
: problem.canViewBy(this.pdoc, this.user) ? 'correction' : 'none',
337341
};
338342
if (this.tdoc && this.tsdoc) {
339343
const fields = ['attend', 'startAt'];
@@ -802,7 +806,7 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
802806
@param('filename', Types.Filename)
803807
@param('noDisposition', Types.Boolean)
804808
@query('tid', Types.ObjectId, true)
805-
async get(domainId: string, type = 'additional_file', filename: string, noDisposition = false, tid: ObjectId) {
809+
async get({ }, type = 'additional_file', filename: string, noDisposition = false, tid: ObjectId) {
806810
if (!tid) this.checkPerm(PERM.PERM_VIEW_PROBLEM);
807811
if (this.pdoc.reference) {
808812
if (type === 'testdata') throw new ProblemIsReferencedError('download testdata');

packages/ui-default/locales/zh.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Copy Selected: 复制选中
223223
Copy WeChat Account: 复制微信号
224224
Copy: 复制
225225
Copyright Complaint: 版权申诉
226+
Correction: 补题
226227
CPU Info: CPU信息
227228
Create a contest: 创建一个比赛
228229
Create a Discussion: 创建一个讨论
@@ -914,6 +915,7 @@ Testdata: 测试数据
914915
Text: 文本
915916
The 'default' role applies to ALL REGISTERED USER.: default 角色作用于<b>所有已注册用户</b>
916917
The contest is a flexible time contest. You need to complete the contest within a specified time after you attended.: 本场比赛采用灵活时间模式,你需要在参加后的指定时间内完成比赛。
918+
The contest is ended. New submissions will be treated as correction submissions and will not be counted in the contest.: 比赛已经结束。新提交将被视为补题提交,不计入比赛成绩。
917919
The group to join when user joining the domain.: 加入域时自动加入的小组。
918920
The homework's deadline is due but in extension. You can still submit for this problem but your score will be penalized.: 作业已超过截止时间,但仍在延期时间内。您递交题目将无法获得全部分数。
919921
The invitation code to enter to successfully join the domain. You can only use letters and numbers in the code and it should not be longer than 64 characters.: 加入此域的邀请码。您只能使用字母和数字,并且不能长于 64 个字符。

packages/ui-default/pages/contest.page.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ $highlight-button-color = #F6DF45
110110
width: auto
111111

112112
.page--contest_problemlist
113-
.col--status
113+
.col--status, .col--correction
114114
width: rem(150px)
115115

116116
.col--submit-at
@@ -128,7 +128,7 @@ $highlight-button-color = #F6DF45
128128
border-left: 1px solid $table-border-color
129129

130130
+mobile()
131-
.col--submit-at
131+
.col--submit-at, .col--correction
132132
display: none
133133

134134
+tablet()

packages/ui-default/templates/contest_problemlist.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{% block content %}
66
{{ set(UiContext, 'tdoc', tdoc) }}
77
{{ set(UiContext, 'tsdoc', tsdoc) }}
8+
{% set hasCorrection = correction and Object.keys(correction).length %}
89
<div class="row" data-sticky-parent>
910
<div class="medium-9 columns">
1011
<div class="section">
@@ -27,7 +28,11 @@ <h1 class="section__title">{{ _('Problems') }}</h1>
2728
<tr>
2829
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
2930
<th class="col--status record-status--border">{{ _('Status') }}</th>
30-
<th class="col--submit-at">{{ _('Last Submit At') }}</th>
31+
{% if hasCorrection %}
32+
<th class="col--correction">{{ _('Correction') }}</th>
33+
{% else %}
34+
<th class="col--submit-at">{{ _('Last Submit At') }}</th>
35+
{% endif %}
3136
{% endif %}
3237
{% if showScore %}
3338
<th class="col--score">{{ _('Score') }}</th>
@@ -47,10 +52,21 @@ <h1 class="section__title">{{ _('Problems') }}</h1>
4752
{% else %}
4853
<td class="col--status record-status--border"><a href="{{ url('record_detail', rid=rdoc._id) }}">{{ _('Submitted') }}</a></td>
4954
{% endif %}
50-
<td class="col--submit-at">{{ datetimeSpan(rdoc._id)|safe }}</td>
55+
{% if not hasCorrection %}
56+
<td class="col--submit-at">{{ datetimeSpan(rdoc._id)|safe }}</td>
57+
{% endif %}
5158
{% else %}
5259
<td class="col--status record-status--border">{{ _('No Submissions') }}</td>
53-
<td class="col--submit-at">-</td>
60+
{% if not hasCorrection %}
61+
<td class="col--submit-at">-</td>
62+
{% endif %}
63+
{% endif %}
64+
{% if hasCorrection %}
65+
{% if correction[pid] %}
66+
{{ record.render_status_td(rdict[correction[pid].rid], class="col--correction") }}
67+
{% else %}
68+
<td class="col--correction">-</td>
69+
{% endif %}
5470
{% endif %}
5571
{% endif %}
5672
{% if showScore %}

packages/ui-default/templates/partials/problem_description.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
<p>{{ _('No submission language available for this problem.') }}</p>
1515
</blockquote>
1616
{% endif %}
17-
{% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %}
17+
{% if tdoc and tdoc.docType == model.document.TYPE_CONTEST %}
18+
{% if mode == 'view' %}
1819
<blockquote class="note">
1920
<p>{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}</p>
2021
</blockquote>
22+
{% elif mode == 'correction' %}
23+
<blockquote class="note">
24+
<p>{{ _('The contest is ended. New submissions will be treated as correction submissions and will not be counted in the contest.') }}</p>
25+
</blockquote>
26+
{% endif %}
2127
{% endif %}
2228
{% if not renderredContent %}
2329
{% set preferredLang = handler.request.query.lang or handler.user.viewLang or handler.session.viewLang %}

packages/ui-default/templates/partials/problem_sidebar_contest.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h1 class="section__title">{{ pdoc['title'] }}</h1>
77
{% endif %}
88
<div>
99
<ol class="menu">
10-
{% if model.contest.isOngoing(tdoc, tsdoc) %}
10+
{% if mode == 'contest' or mode == 'correction' %}
1111
{% if page_name == 'contest_detail_problem' %}
1212
<li class="menu__item scratchpad--hide nojs--hide"><a class="menu__link highlight" name="problem-sidebar__open-scratchpad" href="javascript:;" data-global-hotkey="alt+e">
1313
<span class="icon icon-enlarge"></span> {{ _('Open Scratchpad') }} (Alt+E)
@@ -20,10 +20,11 @@ <h1 class="section__title">{{ pdoc['title'] }}</h1>
2020
<span class="icon icon-flag"></span> {{ _('View Problem') }}
2121
</a></li>
2222
{% endif %}
23-
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'contest_detail_problem_submit' %} active{% endif %}" href="{{ url('problem_submit', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}">
23+
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'contest_detail_problem_submit' %} active{% endif %}" href="{{ url('problem_submit', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId} if mode=='contest' else {}) }}">
2424
<span class="icon icon-send"></span> {{ _('Submit') }}
2525
</a></li>
26-
{% elif model.contest.isDone(tdoc) %}
26+
{% endif %}
27+
{% if mode != 'none' and model.contest.isDone(tdoc) %}
2728
<li class="menu__item"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}">
2829
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
2930
</a></li>

packages/ui-default/templates/partials/problem_sidebar_normal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="section__title">{{ pdoc['title'] }}</h1>
2828
<li class="menu__seperator"></li>
2929
{% endif %}
3030
{% if page_name == 'problem_detail' %}
31-
{% if handler.user.hasPerm(perm.PERM_SUBMIT_PROBLEM) %}
31+
{% if handler.user.hasPerm(perm.PERM_SUBMIT_PROBLEM) and handler.ctx.setting.get('ui-default.enableScratchpad') %}
3232
<li class="menu__item scratchpad--hide nojs--hide"><a class="menu__link highlight" name="problem-sidebar__open-scratchpad" href="javascript:;" data-global-hotkey="alt+e">
3333
<span class="icon icon-enlarge"></span> {{ _('Open Scratchpad') }} (Alt+E)
3434
</a></li>

packages/ui-default/templates/problem_detail.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
pdoc: pdoc
1010
}) }}
1111
{% if tdoc %}
12+
{{ set(UiContext, 'tdoc', tdoc) }}
13+
{{ set(UiContext, 'tsdoc', tsdoc) }}
14+
{% endif %}
15+
{% if tdoc and mode == 'contest' %}
1216
{{ set(UiContext, 'canViewRecord', model.contest.canShowSelfRecord.call(handler, tdoc)) }}
1317
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId, query={tid:tdoc.docId})) }}
1418
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={fullStatus:'true', pid:pdoc.docId, tid:tdoc.docId})) }}
1519
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
1620
{{ set(UiContext, 'pretestConnUrl', "record-conn?pretest=1&uidOrName=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.args.domainId + "&tid=" + tdoc.docId) }}
17-
{{ set(UiContext, 'tdoc', tdoc) }}
18-
{{ set(UiContext, 'tsdoc', tsdoc) }}
1921
{% else %}
2022
{{ set(UiContext, 'canViewRecord', true) }}
2123
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId)) }}

0 commit comments

Comments
 (0)