diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 42e15ff6b..4680d34e6 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -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( diff --git a/packages/hydrooj/src/handler/record.ts b/packages/hydrooj/src/handler/record.ts index b7de7ed63..ea44b2111 100644 --- a/packages/hydrooj/src/handler/record.ts +++ b/packages/hydrooj/src/handler/record.ts @@ -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); diff --git a/packages/hydrooj/src/model/record.ts b/packages/hydrooj/src/model/record.ts index ce2bb0b99..e80500c7b 100644 --- a/packages/hydrooj/src/model/record.ts +++ b/packages/hydrooj/src/model/record.ts @@ -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) { diff --git a/packages/ui-default/templates/record_detail.html b/packages/ui-default/templates/record_detail.html index a6cbab979..f0f0ad230 100644 --- a/packages/ui-default/templates/record_detail.html +++ b/packages/ui-default/templates/record_detail.html @@ -24,7 +24,7 @@

{{ _('Information') }}

- {% if handler.user.hasPerm(perm.PERM_REJUDGE) %} + {% if handler.user.hasPerm(perm.PERM_REJUDGE) and not rdoc.files.hack %}
{% 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 %}