mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: 导出比赛代码功能
This commit is contained in:
1 parent
cc08538bdb
commit
b062aa84bf
3 files changed
+8
-10
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.27.1",
|
||||
"version": "2.27.2",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -372,15 +372,13 @@ class ContestCodeHandler extends Handler {
|
||||
const [tdoc, tsdocs] = await contest.getAndListStatus(domainId, tid);
|
||||
const rnames = {};
|
||||
for (const tsdoc of tsdocs) {
|
||||
for (const pdetail of tsdoc.detail || []) {
|
||||
rnames[pdetail.rid] = `U${tsdoc.uid}_P${pdetail.pid}_R${pdetail.rid}`;
|
||||
for (const pid in tsdoc.detail || {}) {
|
||||
rnames[tsdoc.detail[pid].rid] = `U${tsdoc.uid}_P${pid}_R${tsdoc.detail[pid].rid}`;
|
||||
}
|
||||
}
|
||||
const zip = new AdmZip();
|
||||
const rdocs = await record.getMulti(domainId, {
|
||||
_id: {
|
||||
$in: Array.from(Object.keys(rnames)).map((id) => new ObjectID(id)),
|
||||
},
|
||||
_id: { $in: Array.from(Object.keys(rnames)).map((id) => new ObjectID(id)) },
|
||||
}).toArray();
|
||||
for (const rdoc of rdocs) {
|
||||
zip.addFile(`${rnames[rdoc._id.toHexString()]}.${rdoc.lang}`, Buffer.from(rdoc.code));
|
||||
@@ -393,7 +391,7 @@ class ContestCreateHandler extends Handler {
|
||||
async get() {
|
||||
this.response.template = 'contest_edit.html';
|
||||
const rules = {};
|
||||
for (const i in contest.RULES) { rules[i] = contest.RULES[i].TEXT; }
|
||||
for (const i in contest.RULES) rules[i] = contest.RULES[i].TEXT;
|
||||
const now = new Date();
|
||||
let ts = now.getTime();
|
||||
ts = ts - (ts % (15 * 60 * 1000)) + 15 * 60 * 1000;
|
||||
|
||||
@@ -405,8 +405,8 @@ class HomeworkCodeHandler extends Handler {
|
||||
);
|
||||
const rnames = {};
|
||||
for (const tsdoc of tsdocs) {
|
||||
for (const pdetail of tsdoc.detail || []) {
|
||||
rnames[pdetail.rid] = `U${tsdoc.uid}_P${pdetail.pid}_R${pdetail.rid}`;
|
||||
for (const pid in tsdoc.detail || {}) {
|
||||
rnames[tsdoc.detail[pid].rid] = `U${tsdoc.uid}_P${pid}_R${tsdoc.detail[pid].rid}`;
|
||||
}
|
||||
}
|
||||
const zip = new AdmZip();
|
||||
@@ -418,7 +418,7 @@ class HomeworkCodeHandler extends Handler {
|
||||
for (const rdoc of rdocs) {
|
||||
zip.addFile(`${rnames[rdoc._id.toHexString()]}.${rdoc.lang}`, Buffer.from(rdoc.code));
|
||||
}
|
||||
await this.binary(zip.toBuffer(), `${tdoc.title}.zip`);
|
||||
this.binary(zip.toBuffer(), `${tdoc.title}.zip`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user