Skip to content

Commit

Permalink
Passcode (CTF Flag) Function (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrjk authored Mar 27, 2020
1 parent 0299029 commit e5e68b5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions vj4/handler/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ def split_tags(self, s):
@base.sanitize
async def post(self, *, pid: document.convert_doc_id, hidden: bool=False,
category: str, tag: str,
difficulty_setting: int, difficulty_admin: str=''):
difficulty_setting: int, difficulty_admin: str='',
ac_msg: str=''):
pdoc = await problem.get(self.domain_id, pid)
if not self.own(pdoc, builtin.PERM_EDIT_PROBLEM_SELF):
self.check_perm(builtin.PERM_EDIT_PROBLEM)
Expand All @@ -728,7 +729,8 @@ async def post(self, *, pid: document.convert_doc_id, hidden: bool=False,
difficulty_admin = None
await problem.edit(self.domain_id, pdoc['doc_id'], hidden=hidden,
category=category, tag=tag,
difficulty_setting=difficulty_setting, difficulty_admin=difficulty_admin)
difficulty_setting=difficulty_setting, difficulty_admin=difficulty_admin,
ac_msg=ac_msg)
await job.difficulty.update_problem(self.domain_id, pdoc['doc_id'])
self.json_or_redirect(self.reverse_url('problem_detail', pid=pid))

Expand Down
4 changes: 3 additions & 1 deletion vj4/locale/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ Created By: 创建人
Judged By: 评测机
Categories: 分类
Tags: 标签
AC Message: 通过消息
problem-category-delim: '|'
problem-subcategory-delim:
Download Dataset: 下载数据集
Expand Down Expand Up @@ -790,4 +791,5 @@ Copy Problem To: 将题目复制到
What's this?: 这是什么?
About test data: 关于测试数据
With this feature, you can copy problems that you can view from a domain to some other domain. Their title, content, tags and categories will be copied. However, their test data are not copied directly.: 您可以通过这个功能将某域下您能查看的题目复制到其它域中,题目的标题、描述、标签与分类将被复制过来。但是测试数据不会被直接复制。
Instead of copying the test data directly, the test data of the copied problems will be linked to the test data of the source problems (called the source test data). Thus, the copied problems can observe the changes in the source test data. The permissions of the test data of the copied problems follow the source test data, e.g., you still might not download them but the judges can. By uploading some new test data, the link will be broken and the new test data will be used.: 虽然测试数据不会被复制,但是系统会将题目的测试数据链接到原题。因此在原题的数据被改动的时候,复制后的题目的数据也会同时改动。链接后的测试数据的权限以原题为准,比如您可能依旧无法下载数据,但是评测机可以。在题目设置页面中可以通过上传新的测试数据的方式,这个数据链接会被删除,以后将使用您的新测试数据。
Instead of copying the test data directly, the test data of the copied problems will be linked to the test data of the source problems (called the source test data). Thus, the copied problems can observe the changes in the source test data. The permissions of the test data of the copied problems follow the source test data, e.g., you still might not download them but the judges can. By uploading some new test data, the link will be broken and the new test data will be used.: 虽然测试数据不会被复制,但是系统会将题目的测试数据链接到原题。因此在原题的数据被改动的时候,复制后的题目的数据也会同时改动。链接后的测试数据的权限以原题为准,比如您可能依旧无法下载数据,但是评测机可以。在题目设置页面中可以通过上传新的测试数据的方式,这个数据链接会被删除,以后将使用您的新测试数据。
This message will be presented to those whose submissions are accepted.: 这条消息将会被展示给通过此题的用户。
3 changes: 2 additions & 1 deletion vj4/model/adaptor/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async def copy(pdoc, dest_domain_id: str, owner_uid: int,
pid = await add(domain_id=dest_domain_id, owner_uid=owner_uid,
title=pdoc['title'], content=pdoc['content'],
pid=pid, hidden=hidden, category=pdoc['category'],
data=data, tag=pdoc.get('tag', []))
data=data, tag=pdoc.get('tag', []),
ac_msg=pdoc.get('ac_msg', ''))
await document.inc(src_domain_id, document.TYPE_PROBLEM, src_pid, 'num_be_copied', 1)
return pid

Expand Down
4 changes: 2 additions & 2 deletions vj4/ui/components/scratchpad/ScratchpadToolbarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class ScratchpadToolbarContainer extends React.PureComponent {
{' '}
{i18n('Run Pretest')}
{' '}
(F9)
(F9)
</ToolbarButton>
<ToolbarButton
disabled={this.props.isPosting}
Expand All @@ -107,7 +107,7 @@ export default class ScratchpadToolbarContainer extends React.PureComponent {
{' '}
{i18n('Submit Solution')}
{' '}
(F10)
(F10)
</ToolbarButton>
<ToolbarItem>
<select
Expand Down
4 changes: 4 additions & 0 deletions vj4/ui/templates/partials/problem_sidebar_normal.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ <h1 class="section__title">{{ _('Information') }}</h1>
{{ _('(None)') }}
{% endif %}
</dd>
{% if pdoc['ac_msg'] and pdoc['psdoc']['status'] == vj4.constant.record.STATUS_ACCEPTED %}
<dt>{{ _('AC Message') }}</dt>
<dd>{{ pdoc['ac_msg'] }}</dd>
{% endif %}
{% endif %}
{% endif %}
<dt>{{ _('Difficulty') }}</dt>
Expand Down
1 change: 1 addition & 0 deletions vj4/ui/templates/problem_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1 class="section__title">{{ _('Settings') }}</h1>
{{ form.form_checkbox(label='Hidden', help_text='Note: Problem title may not be hidden.', name='hidden', value=pdoc['hidden']) }}
{{ form.form_text(columns=12, label='Category', help_text='Format: category 1, sub category 1.1, sub category 1.2, ..., sub category 1.x, ..., category n, sub category n.1, sub category n.2, ..., sub category n.m, ...', name='category', value=pdoc['category']|join(', ')) }}
{{ form.form_text(columns=12, label='Tags', help_text='Splitted by \', \'.', name='tag', value=pdoc['tag']|join(', ')) }}
{{ form.form_text(columns=12, label='AC Message', help_text='This message will be presented to those whose submissions are accepted.', name='ac_msg', value=(pdoc['ac_msg'] or '' )) }}
<div class="row">
{{ form.form_select(columns=4, label='Difficulty', name='difficulty_setting', options=vj4.model.adaptor.problem.SETTING_DIFFICULTY_RANGE.items(), value=pdoc['difficulty_setting']|default(0), row=false) }}
{{ form.form_text(columns=4, label='Evaluated difficulty', help_text='Effects only when Difficulty is not \'Use algorithm calculated\'.', name='difficulty_admin', placeholder='9', value=pdoc['difficulty_admin'] or '', row=False) }}
Expand Down

0 comments on commit e5e68b5

Please sign in to comment.