From 38b5d8d1ace14c7402fa5f4dd73fb091d6b812dd Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 30 Aug 2021 22:48:30 +0800 Subject: [PATCH] ui: disable pretest for remote_judge --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 1 + packages/hydrooj/src/model/contest.ts | 2 +- .../scratchpad/ScratchpadToolbarContainer.jsx | 50 ++++++++++--------- packages/ui-default/package.json | 2 +- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 47428d3ea..4eee69bad 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.33.15", + "version": "2.33.16", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index a78d56b67..00c413f6e 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -294,6 +294,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler { if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) { throw new BadRequestError('Language not allowed.'); } + if (pretest && this.response.body.pdoc.config?.type !== 'default') throw new BadRequestError('unable to run pretest'); await this.limitRate('add_record', 60, system.get('limit.submission')); const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, pretest ? input : undefined); const rdoc = await record.get(domainId, rid); diff --git a/packages/hydrooj/src/model/contest.ts b/packages/hydrooj/src/model/contest.ts index 5c9103924..37ff46762 100644 --- a/packages/hydrooj/src/model/contest.ts +++ b/packages/hydrooj/src/model/contest.ts @@ -46,7 +46,7 @@ const acm: ContestRule = { let time = 0; for (const j of journal) { if (tdoc.pids.includes(j.pid) - && !(effective[j.pid]?.status === STATUS.STATUS_ACCEPTED)) { + && effective[j.pid]?.status !== STATUS.STATUS_ACCEPTED) { effective[j.pid] = j; if (![STATUS.STATUS_ACCEPTED, STATUS.STATUS_COMPILE_ERROR].includes(j.status)) { naccept[j.pid] = (naccept[j.pid] || 0) + 1; diff --git a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx index eb7698d54..c448dc90d 100644 --- a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx +++ b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx @@ -92,19 +92,21 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool if (!keys.includes(this.props.editorLang)) this.props.setEditorLanguage(keys[0]); return ( - this.props.postPretest(this.props)} - data-global-hotkey="f9" - data-tooltip={`${i18n('Pretest Your Code')} (F9)`} - > - - {' '} - {i18n('Run Pretest')} - {' '} - (F9) - + {UiContext.pdoc.config?.type === 'default' && ( + this.props.postPretest(this.props)} + data-global-hotkey="f9" + data-tooltip={`${i18n('Pretest Your Code')} (F9)`} + > + + {' '} + {i18n('Run Pretest')} + {' '} + (F9) + + )} - this.props.togglePanel('pretest')} - data-global-hotkey="alt+p" - data-tooltip={`${i18n('Toggle Pretest Panel')} (Alt+P)`} - > - - {' '} - {i18n('Pretest')} - + {UiContext.pdoc.config?.type === 'default' && ( + this.props.togglePanel('pretest')} + data-global-hotkey="alt+p" + data-tooltip={`${i18n('Toggle Pretest Panel')} (Alt+P)`} + > + + {' '} + {i18n('Pretest')} + + )} {UiContext.canViewRecord && ( ", "license": "AGPL-3.0", "main": "hydro.js",