use files hack for rejudge

pull/427/head
panda 2 years ago committed by undefined
parent bb7ee5cbf9
commit 9621f654c5

@ -434,7 +434,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
const rdocs = await record.getMulti(domainId, {
pid,
contest: { $ne: new ObjectID('0'.repeat(24)) },
status: { $ne: [STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL] },
'files.hack': { $exists: false },
}).project({ _id: 1, contest: 1 }).toArray();
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
await Promise.all(rdocs.map(

@ -171,11 +171,13 @@ class RecordDetailHandler extends Handler {
}
@param('rid', Types.ObjectID)
async postRejudge(domainId: string, rid: ObjectID) {
async post() {
this.checkPerm(PERM.PERM_REJUDGE);
if ([STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL].includes(this.rdoc.status)) {
throw new ForbiddenError('Cannot rejudge a hack record.');
if (this.rdoc.files?.hack) throw new ForbiddenError('Cannot rejudge a hack record.');
}
@param('rid', Types.ObjectID)
async postRejudge(domainId: string, rid: ObjectID) {
const priority = await record.submissionPriority(this.user._id, -20);
const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000';
await record.reset(domainId, rid, true);

@ -24,6 +24,7 @@ class RecordModel {
'_id', 'score', 'time', 'memory', 'lang',
'uid', 'pid', 'rejudged', 'progress', 'domainId',
'contest', 'judger', 'judgeAt', 'status', 'source',
'files',
];
static async submissionPriority(uid: number, base: number = 0) {

@ -24,7 +24,7 @@
<div class="section__header">
<h1 class="section__title">{{ _('Information') }}</h1>
</div>
{% if handler.user.hasPerm(perm.PERM_REJUDGE) %}
{% if handler.user.hasPerm(perm.PERM_REJUDGE) and not rdoc.files.hack %}
<div class="section__body no-padding">
<ol class="menu">
<li class="menu__item">
@ -48,7 +48,7 @@
</ol>
</div>
{% endif %}
{% if handler.user.hasPerm(perm.PERM_SUBMIT_PROBLEM) and pdoc.config.hackable and rdoc.status === STATUS.STATUS_ACCEPTED %}
{% if handler.user.hasPerm(perm.PERM_SUBMIT_PROBLEM) and pdoc.config.hackable and rdoc.status === STATUS.STATUS_ACCEPTED and rdoc.uid !== handler.user._id %}
<div class="section__body no-padding">
<ol class="menu">
<li class="menu__item">

@ -3,7 +3,7 @@
<tr data-rid="{{ rdoc['_id'] }}">
{{ record.render_status_td(rdoc, allDomain = all) }}
<td class="col--problem col--problem-name">
{% if handler.user.hasPerm(perm.PERM_REJUDGE) and rdoc['status'] == STATUS.STATUS_HACK_SUCCESSFUL and rdoc['status'] == STATUS.STATUS_HACK_UNSUCCESSFUL %}
{% if handler.user.hasPerm(perm.PERM_REJUDGE) and not rdoc.files.hack %}
<form class="form--inline" method="post" action="{{ url('record_detail', rid=rdoc._id, domainId=rdoc.domainId) }}">
<input type="hidden" name="operation" value="rejudge">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
@ -20,7 +20,8 @@
{% else %}
*
{% endif %}
{% if rdoc.input %}({{ _('Pretest') }}){% endif %}
{% if rdoc.files.hack %}<span class="text-orange">({{ _('Hack') }})</span>{% endif %}
{% if rdoc.contest and rdoc.contest.toHexString() == '000000000000000000000000' %}<span class="text-orange">(({{ _('Pretest') }})</span>{% endif %}
</td>
<td class="col--submit-by">
<a href="{{ url('user_detail', uid=rdoc.uid) }}">

Loading…
Cancel
Save