mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fps: 支持导入题解
This commit is contained in:
1 parent
addda1b789
commit
34a2259dd9
5 files changed
+18
-9
No files matched your search
+2
-2
@@ -20,7 +20,7 @@
|
|||||||
"@shelf/jest-mongodb": "^1.2.3",
|
"@shelf/jest-mongodb": "^1.2.3",
|
||||||
"@types/cross-spawn": "^6.0.2",
|
"@types/cross-spawn": "^6.0.2",
|
||||||
"@types/jest": "^26.0.14",
|
"@types/jest": "^26.0.14",
|
||||||
"@types/node": "^14.14.7",
|
"@types/node": "^14.14.8",
|
||||||
"@types/semver": "^7.3.4",
|
"@types/semver": "^7.3.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
"@typescript-eslint/parser": "^3.9.1",
|
||||||
@@ -39,6 +39,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"yargs": "^16.0.3"
|
"yargs": "^16.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
import { streamToBuffer } from 'hydrooj/dist/utils';
|
import { streamToBuffer } from 'hydrooj/dist/utils';
|
||||||
import { ProblemAdd } from 'hydrooj/dist/lib/ui';
|
import { ProblemAdd } from 'hydrooj/dist/lib/ui';
|
||||||
import * as file from 'hydrooj/dist/model/file';
|
import * as file from 'hydrooj/dist/model/file';
|
||||||
|
import * as solution from 'hydrooj/dist/model/solution';
|
||||||
import { PERM } from 'hydrooj/dist/model/builtin';
|
import { PERM } from 'hydrooj/dist/model/builtin';
|
||||||
|
|
||||||
const processing = {};
|
const processing = {};
|
||||||
@@ -116,7 +117,7 @@ class FpsProblemImportHandler extends Handler {
|
|||||||
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[i]));
|
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[i]));
|
||||||
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_output[i]));
|
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_output[i]));
|
||||||
}
|
}
|
||||||
} else {
|
} else if (p.test_input) {
|
||||||
for (let i = 0; i < p.test_input.length / 2; i++) {
|
for (let i = 0; i < p.test_input.length / 2; i++) {
|
||||||
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[2 * i]));
|
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[2 * i]));
|
||||||
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_input[2 * i + 1]));
|
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_input[2 * i + 1]));
|
||||||
@@ -131,6 +132,14 @@ class FpsProblemImportHandler extends Handler {
|
|||||||
});
|
});
|
||||||
await problem.setTestdata(domainId, pid, f);
|
await problem.setTestdata(domainId, pid, f);
|
||||||
await problem.edit(domainId, pid, { html: true });
|
await problem.edit(domainId, pid, { html: true });
|
||||||
|
if (p.solution) {
|
||||||
|
let s = '';
|
||||||
|
for (const sol of p.solution) {
|
||||||
|
s += `**${sol.$.language}** : \n\`\`\`\n${sol._}\n\`\`\`\n`;
|
||||||
|
}
|
||||||
|
console.log(domainId, pid, this.user._id, s);
|
||||||
|
await solution.add(domainId, pid, this.user._id, s);
|
||||||
|
}
|
||||||
await fs.unlink(f);
|
await fs.unlink(f);
|
||||||
}
|
}
|
||||||
this.response.body = { count: result.fps.item.length };
|
this.response.body = { count: result.fps.item.length };
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/fps-importer",
|
"name": "@hydrooj/fps-importer",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "Import FPS problems",
|
"description": "Import FPS problems",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"xml2js": "^0.4.23"
|
"xml2js": "^0.4.23"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/xml2js": "^0.4.5",
|
"@types/xml2js": "^0.4.7",
|
||||||
"bson": "^4.1.0"
|
"bson": "^4.1.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"shell-quote": "^1.7.2",
|
"shell-quote": "^1.7.2",
|
||||||
"supports-color": "^7.2.0",
|
"supports-color": "^7.2.0",
|
||||||
"systeminformation": "^4.30.1",
|
"systeminformation": "^4.30.1",
|
||||||
"yargs": "^16.1.0"
|
"yargs": "^16.1.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"hydrooj": "^2.13.3"
|
"hydrooj": "^2.13.3"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"koa-static-cache": "^5.1.3",
|
"koa-static-cache": "^5.1.3",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"lru-cache": "^6.0.0",
|
"lru-cache": "^6.0.0",
|
||||||
"moment-timezone": "^0.5.31",
|
"moment-timezone": "^0.5.32",
|
||||||
"mongodb": "^3.6.3",
|
"mongodb": "^3.6.3",
|
||||||
"nodemailer": "^6.4.16",
|
"nodemailer": "^6.4.16",
|
||||||
"ps-list": "^7.2.0",
|
"ps-list": "^7.2.0",
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"superagent": "^6.1.0",
|
"superagent": "^6.1.0",
|
||||||
"supports-color": "^7.2.0",
|
"supports-color": "^7.2.0",
|
||||||
"systeminformation": "^4.30.1",
|
"systeminformation": "^4.30.1",
|
||||||
"yargs": "^16.0.3"
|
"yargs": "^16.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/adm-zip": "^0.4.33",
|
"@types/adm-zip": "^0.4.33",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"@types/sockjs": "^0.3.32",
|
"@types/sockjs": "^0.3.32",
|
||||||
"@types/superagent": "^4.1.8",
|
"@types/superagent": "^4.1.8",
|
||||||
"@types/supports-color": "^7.2.0",
|
"@types/supports-color": "^7.2.0",
|
||||||
"@types/yargs": "^15.0.7"
|
"@types/yargs": "^15.0.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
|||||||
Reference in new issue
Block a user