core: remove getTestdata option

This commit is contained in:
undefined committed 2023-02-12 16:20:50 +08:00
1 parent 0200c7b168
commit 254f659f0a
3 files changed
+12 -13

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "4.7.3", "version": "4.7.4",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/plugin-api", "main": "src/plugin-api",
"module": "src/plugin-api", "module": "src/plugin-api",
+3 -3
View File
@@ -282,7 +282,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
async exportGhost(domainId: string, tid: ObjectID) { async exportGhost(domainId: string, tid: ObjectID) {
const tdoc = this.tdoc; const tdoc = this.tdoc;
const [pdict, teams] = await Promise.all([ 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(), contest.getMultiStatus(domainId, { docId: tid }).toArray(),
]); ]);
const udict = await user.getList(domainId, teams.map((i) => i.uid)); const udict = await user.getList(domainId, teams.map((i) => i.uid));
@@ -309,7 +309,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
`@teams ${tdoc.attend}`, `@teams ${tdoc.attend}`,
`@submissions ${submissions.length}`, `@submissions ${submissions.length}`,
].concat( ].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)}`), teams.map((i, idx) => `@t ${idx + 1},0,1,${escape(udict[i.uid].school || unknownSchool)}-${escape(udict[i.uid].uname)}`),
submissions, submissions,
); );
@@ -395,7 +395,7 @@ export class ContestEditHandler extends Handler {
domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string, duration: number, domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string, duration: number,
title: string, content: string, rule: string, _pids: string, rated = false, title: string, content: string, rule: string, _pids: string, rated = false,
_code = '', autoHide = false, assign: string[] = null, lock: number = null, _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); if (autoHide) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i); const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
+8 -9
View File
@@ -666,23 +666,22 @@ export class ProblemConfigHandler extends ProblemManageHandler {
export class ProblemFilesHandler extends ProblemDetailHandler { export class ProblemFilesHandler extends ProblemDetailHandler {
notUsage = true; notUsage = true;
@param('testdata', Types.Boolean)
@param('additional_file', Types.Boolean)
@param('pjax', Types.Boolean) @param('pjax', Types.Boolean)
@param('sidebar', Types.Boolean) @param('sidebar', Types.Boolean)
async get(domainId: string, getTestdata = true, getAdditionalFile = true, pjax = false, sidebar = false) { async get(domainId: string, pjax = false, sidebar = false) {
this.response.body.testdata = getTestdata ? sortFiles(this.pdoc.data || []) : []; this.response.body.testdata = sortFiles(this.pdoc.data || []);
this.response.body.reference = getTestdata ? this.pdoc.reference : ''; this.response.body.reference = this.pdoc.reference;
this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : []; this.response.body.additional_file = sortFiles(this.pdoc.additional_file || []);
if (pjax) { if (pjax) {
const { testdata, additional_file } = this.response.body; const { testdata, additional_file } = this.response.body;
const owner = await user.getById(domainId, this.pdoc.owner); const owner = await user.getById(domainId, this.pdoc.owner);
const args = { const args = {
testdata, additional_file, pdoc: this.pdoc, owner_udoc: owner, sidebar, testdata, additional_file, pdoc: this.pdoc, owner_udoc: owner, sidebar,
}; };
const tasks = []; const tasks = [
if (getTestdata) tasks.push(this.renderHTML('partials/problem_files.html', { ...args, filetype: 'testdata' })); this.renderHTML('partials/problem_files.html', { ...args, filetype: 'testdata' }),
if (getAdditionalFile) tasks.push(this.renderHTML('partials/problem_files.html', { ...args, filetype: 'additional_file' })); this.renderHTML('partials/problem_files.html', { ...args, filetype: 'additional_file' }),
];
if (!sidebar) tasks.push(this.renderHTML('partials/problem-sidebar-information.html', args)); if (!sidebar) tasks.push(this.renderHTML('partials/problem-sidebar-information.html', args));
this.response.body = { this.response.body = {
fragments: (await Promise.all(tasks)).map((i) => ({ html: i })), fragments: (await Promise.all(tasks)).map((i) => ({ html: i })),