diff --git a/packages/hydrooj/src/error.ts b/packages/hydrooj/src/error.ts index 8578c314d..9b001439b 100644 --- a/packages/hydrooj/src/error.ts +++ b/packages/hydrooj/src/error.ts @@ -114,6 +114,7 @@ export const ProblemAlreadyUsedByContestError = Err('ProblemAlreadyUsedByContest export const ProblemNotAllowPretestError = Err('ProblemNotAllowPretestError', ForbiddenError, 'Pretesting is not supported for {0}.'); export const ProblemNotAllowLanguageError = Err('ProblemNotAllowSubmitError', ForbiddenError, 'This language is not allowed to submit.'); +export const PretestRejudgeFailedError = Err('PretestRejudgeFailedError', BadRequestError, 'Cannot rejudge a pretest record.'); export const HackRejudgeFailedError = Err('HackRejudgeFailedError', BadRequestError, 'Cannot rejudge a hack record.'); export const CannotDeleteSystemDomainError = Err('CannotDeleteSystemDomainError', BadRequestError, 'You are not allowed to delete system domain.'); export const OnlyOwnerCanDeleteDomainError = Err('OnlyOwnerCanDeleteDomainError', BadRequestError, 'You are not the owner of this domain.'); diff --git a/packages/hydrooj/src/handler/record.ts b/packages/hydrooj/src/handler/record.ts index 4750d29d9..1481daae2 100644 --- a/packages/hydrooj/src/handler/record.ts +++ b/packages/hydrooj/src/handler/record.ts @@ -4,7 +4,7 @@ import { import { Filter, ObjectId } from 'mongodb'; import { ContestNotFoundError, HackRejudgeFailedError, - PermissionError, ProblemConfigError, + PermissionError, PretestRejudgeFailedError, ProblemConfigError, ProblemNotFoundError, RecordNotFoundError, UserNotFoundError, } from '../error'; import { RecordDoc, Tdoc } from '../interface'; @@ -177,7 +177,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler { // eslint-disable-next-line prefer-const let [pdoc, self, udoc] = await Promise.all([ - problem.get(rdoc.domainId, rdoc.pid), + problem.get(rdoc.domainId, rdoc.pid, problem.PROJECTION_LIST), problem.getStatus(domainId, rdoc.pid, this.user._id), user.getById(domainId, rdoc.uid), ]); @@ -209,6 +209,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler { async post() { this.checkPerm(PERM.PERM_REJUDGE); if (this.rdoc.files?.hack) throw new HackRejudgeFailedError(); + if (this.rdoc.contest?.toString().startsWith('0'.repeat(23))) throw new PretestRejudgeFailedError(); } @param('rid', Types.ObjectId) @@ -216,10 +217,9 @@ class RecordDetailHandler extends ContestDetailBaseHandler { const pdoc = await problem.get(domainId, this.rdoc.pid); if (!pdoc?.config || typeof pdoc.config === 'string') throw new ProblemConfigError(); const priority = await record.submissionPriority(this.user._id, -20); - const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000'; const rdoc = await record.reset(domainId, rid, true); this.ctx.broadcast('record/change', rdoc); - await record.judge(domainId, rid, priority, isContest ? { detail: false } : {}); + await record.judge(domainId, rid, priority, this.rdoc.contest ? { detail: false } : {}); this.back(); }