From 254f659f0a7bc0f1fac9f6eed23fcfd170fe15a6 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 12 Feb 2023 16:20:50 +0800 Subject: [PATCH] core: remove getTestdata option --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/contest.ts | 6 +++--- packages/hydrooj/src/handler/problem.ts | 17 ++++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index fdc10b0b0..b5b1a43ac 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "4.7.3", + "version": "4.7.4", "bin": "bin/hydrooj.js", "main": "src/plugin-api", "module": "src/plugin-api", diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index 1cdc4ccd2..6d7463b15 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -282,7 +282,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler { async exportGhost(domainId: string, tid: ObjectID) { const tdoc = this.tdoc; const [pdict, teams] = await Promise.all([ - problem.getList(domainId, tdoc.pids, true, false, undefined, true), + problem.getList(domainId, tdoc.pids, true, false, problem.PROJECTION_LIST, true), contest.getMultiStatus(domainId, { docId: tid }).toArray(), ]); const udict = await user.getList(domainId, teams.map((i) => i.uid)); @@ -309,7 +309,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler { `@teams ${tdoc.attend}`, `@submissions ${submissions.length}`, ].concat( - tdoc.pids.map((i, idx) => `@p ${pid(idx)},${escape(pdict[i].title)},20,0`), + tdoc.pids.map((i, idx) => `@p ${pid(idx)},${escape(pdict[i]?.title || 'Unknown Problem')},20,0`), teams.map((i, idx) => `@t ${idx + 1},0,1,${escape(udict[i.uid].school || unknownSchool)}-${escape(udict[i.uid].uname)}`), submissions, ); @@ -395,7 +395,7 @@ export class ContestEditHandler extends Handler { domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string, duration: number, title: string, content: string, rule: string, _pids: string, rated = false, _code = '', autoHide = false, assign: string[] = null, lock: number = null, - contestDuration: number = null, maintainer: number[] = null, allowViewCode = true, + contestDuration: number = null, maintainer: number[] = null, allowViewCode = false, ) { if (autoHide) this.checkPerm(PERM.PERM_EDIT_PROBLEM); const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i); diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index f7eb06adb..3b64f4771 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -666,23 +666,22 @@ export class ProblemConfigHandler extends ProblemManageHandler { export class ProblemFilesHandler extends ProblemDetailHandler { notUsage = true; - @param('testdata', Types.Boolean) - @param('additional_file', Types.Boolean) @param('pjax', Types.Boolean) @param('sidebar', Types.Boolean) - async get(domainId: string, getTestdata = true, getAdditionalFile = true, pjax = false, sidebar = false) { - this.response.body.testdata = getTestdata ? sortFiles(this.pdoc.data || []) : []; - this.response.body.reference = getTestdata ? this.pdoc.reference : ''; - this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : []; + async get(domainId: string, pjax = false, sidebar = false) { + this.response.body.testdata = sortFiles(this.pdoc.data || []); + this.response.body.reference = this.pdoc.reference; + this.response.body.additional_file = sortFiles(this.pdoc.additional_file || []); if (pjax) { const { testdata, additional_file } = this.response.body; const owner = await user.getById(domainId, this.pdoc.owner); const args = { testdata, additional_file, pdoc: this.pdoc, owner_udoc: owner, sidebar, }; - const tasks = []; - if (getTestdata) tasks.push(this.renderHTML('partials/problem_files.html', { ...args, filetype: 'testdata' })); - if (getAdditionalFile) tasks.push(this.renderHTML('partials/problem_files.html', { ...args, filetype: 'additional_file' })); + const tasks = [ + this.renderHTML('partials/problem_files.html', { ...args, filetype: 'testdata' }), + this.renderHTML('partials/problem_files.html', { ...args, filetype: 'additional_file' }), + ]; if (!sidebar) tasks.push(this.renderHTML('partials/problem-sidebar-information.html', args)); this.response.body = { fragments: (await Promise.all(tasks)).map((i) => ({ html: i })),