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
@@ -14,6 +14,7 @@ import {
|
||||
import { streamToBuffer } from 'hydrooj/dist/utils';
|
||||
import { ProblemAdd } from 'hydrooj/dist/lib/ui';
|
||||
import * as file from 'hydrooj/dist/model/file';
|
||||
import * as solution from 'hydrooj/dist/model/solution';
|
||||
import { PERM } from 'hydrooj/dist/model/builtin';
|
||||
|
||||
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}.out`, Buffer.from(p.test_output[i]));
|
||||
}
|
||||
} else {
|
||||
} else if (p.test_input) {
|
||||
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}.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.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);
|
||||
}
|
||||
this.response.body = { count: result.fps.item.length };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/fps-importer",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "Import FPS problems",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
@@ -13,7 +13,7 @@
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/xml2js": "^0.4.5",
|
||||
"@types/xml2js": "^0.4.7",
|
||||
"bson": "^4.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
Reference in new issue
Block a user