From 50b838d21d63b8814b12d65330b60e2ef9cb709e Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 7 Nov 2022 12:07:15 +0800 Subject: [PATCH] import-qduoj: fix #256 --- packages/import-qduoj/index.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/import-qduoj/index.ts b/packages/import-qduoj/index.ts index a74f1b03e..648f37ba3 100644 --- a/packages/import-qduoj/index.ts +++ b/packages/import-qduoj/index.ts @@ -82,29 +82,39 @@ class ImportQduojHandler extends Handler { memory: `${pdoc.memory_limit}m`, subtasks: [], }; + const tasks = []; for (const tc of pdoc.test_case_score) { - await Promise.all([ - ProblemModel.addTestdata( - domainId, pid, tc.input_name, - path.join(tmp, folder, 'testcase', tc.input_name), - ), - ProblemModel.addTestdata( + tasks.push(ProblemModel.addTestdata( + domainId, pid, tc.input_name, + path.join(tmp, folder, 'testcase', tc.input_name), + )); + if (tc.output_name !== '-') { + tasks.push(ProblemModel.addTestdata( domainId, pid, tc.output_name, path.join(tmp, folder, 'testcase', tc.output_name), - ), - ]); + )); + } config.subtasks.push({ score: tc.score, cases: [{ input: tc.input_name, - output: tc.output_name, + output: tc.output_name === '-' ? '/dev/null' : tc.output_name, }], }); } - await Promise.all([ + if (pdoc.spj?.language === 'C++') { + tasks.push(ProblemModel.addTestdata( + domainId, pid, 'checker.cc', + Buffer.from(pdoc.spj.code), + )); + config.checker = 'checker.cc'; + config.checker_type = 'qduoj'; + } + tasks.push( ProblemModel.addTestdata(domainId, pid, 'config.yaml', Buffer.from(yaml.dump(config))), ProblemModel.edit(domainId, pid, { html: true }), - ]); + ); + await Promise.all(tasks); } } finally { await fs.remove(tmp);