fix: import

This commit is contained in:
undefined committed 2020-09-02 22:54:15 +08:00
1 parent 75da6381ee
commit 86689e8d4c
3 files changed
+27 -22

No files matched your search

+25 -20
View File
@@ -24,40 +24,45 @@ class FpsProblemImportHandler extends Handler {
const content = [];
if (p.description) {
content.push(
this.translate('problem.import.problem_description'),
p.description.join('\n'),
`<h2>${this.translate('Description')}</h2>`,
...p.description,
);
}
if (p.input) {
content.push(
this.translate('problem.import.input_format'),
p.input.join('\n'),
`<h2>${this.translate('Input Format')}</h2>`,
...p.input,
);
}
if (p.output) {
content.push(
this.translate('problem.import.output_format'),
p.output.join('\n'),
`<h2>${this.translate('Output Format')}</h2>`,
...p.output,
);
}
if (p.sample_input) {
content.push(
this.translate('problem.import.sample_input'),
// eslint-disable-next-line prefer-template
p.sample_input.map((i: string) => ('```\n' + i + '\n```')).join('\n'),
);
}
if (p.sample_output) {
content.push(
this.translate('problem.import.sample_output'),
// eslint-disable-next-line prefer-template
p.sample_output.map((i: string) => ('```\n' + i + '\n```')).join('\n'),
);
if (p.sample_input.length === 1) {
content.push(
`<h2>${this.translate('Sample Input')}</h2>`,
`<pre><code>${p.sample_input[0]}</code></pre>`,
`<h2>${this.translate('Sample Output')}</h2>`,
`<pre><code>${p.sample_output[0]}</code></pre>`,
);
} else {
for (let i = 0; i < p.sample_input.length; i++) {
content.push(
`<h2>${this.translate('Sample Input')}${i + 1}</h2>`,
`<pre><code>${p.sample_input[i]}</code></pre>`,
`<h2>${this.translate('Sample Output')}${i + 1}</h2>`,
`<pre><code>${p.sample_output[i]}</code></pre>`,
);
}
}
}
if (p.hint) {
content.push(
this.translate('problem.import.hint'),
p.hint.join('\n'),
`<h2>${this.translate('Hint')}</h2>`,
...p.hint,
);
}
const config: LocalProblemConfig = {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/fps-importer",
"version": "1.0.3",
"version": "1.0.4",
"description": "Import FPS problems",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",
@@ -8,7 +8,7 @@
<div class="row"><div class="columns">
<label>
{{ _('FPS FILE') }}
<textarea name="content" class="textbox" data-xml style="height: 500px"></textarea>
<textarea name="input" class="textbox" data-xml style="height: 500px"></textarea>
</label>
</div></div>
<div class="row"><div class="columns">