mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 18:48:41 +00:00
feat(remote_judger): judge details for codeforces
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e9abdd53ae
commit
50efed50fd
68
remote_judger/package-lock.json
generated
68
remote_judger/package-lock.json
generated
@ -9,6 +9,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"crlf-normalize": "^1.0.18",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"jsdom": "^21.0.0",
|
"jsdom": "^21.0.0",
|
||||||
"math-sum": "^2.0.0",
|
"math-sum": "^2.0.0",
|
||||||
@ -80,8 +81,7 @@
|
|||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "18.11.18",
|
"version": "18.11.18",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
||||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
|
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/@types/superagent": {
|
"node_modules/@types/superagent": {
|
||||||
"version": "4.1.16",
|
"version": "4.1.16",
|
||||||
@ -230,6 +230,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.4.0.tgz",
|
||||||
"integrity": "sha512-9Y5epwkPxnWDSjweuWoFATY8GKg9N1/r/3wL32Cjs7FIvo0S9syyY39xmNKq7+SZjbw+9bZUSbeQSbJaqufV3Q=="
|
"integrity": "sha512-9Y5epwkPxnWDSjweuWoFATY8GKg9N1/r/3wL32Cjs7FIvo0S9syyY39xmNKq7+SZjbw+9bZUSbeQSbJaqufV3Q=="
|
||||||
},
|
},
|
||||||
|
"node_modules/crlf-normalize": {
|
||||||
|
"version": "1.0.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/crlf-normalize/-/crlf-normalize-1.0.18.tgz",
|
||||||
|
"integrity": "sha512-bBPJTekqhw/yUgHvHrOT2QBb6gJt/gNDx++GKkSYaBIepeEiLIezouV8xgDFTL3yRMpK7wOYC9a8xvY7bFQCLg==",
|
||||||
|
"dependencies": {
|
||||||
|
"ts-type": ">=2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cssom": {
|
"node_modules/cssom": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
|
||||||
@ -1298,6 +1306,25 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ts-toolbelt": {
|
||||||
|
"version": "9.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz",
|
||||||
|
"integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/ts-type": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-type/-/ts-type-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-cleRydCkBGBFQ4KAvLH0ARIkciduS745prkGVVxPGvcRGhMMoSJUB7gNR1ByKhFTEYrYRg2CsMRGYnqp+6op+g==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"tslib": ">=2",
|
||||||
|
"typedarray-dts": "^1.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"ts-toolbelt": "^9.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tslib": {
|
"node_modules/tslib": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
||||||
@ -1314,6 +1341,11 @@
|
|||||||
"node": ">= 0.8.0"
|
"node": ">= 0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/typedarray-dts": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/typedarray-dts/-/typedarray-dts-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-Ka0DBegjuV9IPYFT1h0Qqk5U4pccebNIJCGl8C5uU7xtOs+jpJvKGAY4fHGK25hTmXZOEUl9Cnsg5cS6K/b5DA=="
|
||||||
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "4.9.4",
|
"version": "4.9.4",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -1538,8 +1570,7 @@
|
|||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "18.11.18",
|
"version": "18.11.18",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
||||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
|
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@types/superagent": {
|
"@types/superagent": {
|
||||||
"version": "4.1.16",
|
"version": "4.1.16",
|
||||||
@ -1664,6 +1695,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.4.0.tgz",
|
||||||
"integrity": "sha512-9Y5epwkPxnWDSjweuWoFATY8GKg9N1/r/3wL32Cjs7FIvo0S9syyY39xmNKq7+SZjbw+9bZUSbeQSbJaqufV3Q=="
|
"integrity": "sha512-9Y5epwkPxnWDSjweuWoFATY8GKg9N1/r/3wL32Cjs7FIvo0S9syyY39xmNKq7+SZjbw+9bZUSbeQSbJaqufV3Q=="
|
||||||
},
|
},
|
||||||
|
"crlf-normalize": {
|
||||||
|
"version": "1.0.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/crlf-normalize/-/crlf-normalize-1.0.18.tgz",
|
||||||
|
"integrity": "sha512-bBPJTekqhw/yUgHvHrOT2QBb6gJt/gNDx++GKkSYaBIepeEiLIezouV8xgDFTL3yRMpK7wOYC9a8xvY7bFQCLg==",
|
||||||
|
"requires": {
|
||||||
|
"ts-type": ">=2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cssom": {
|
"cssom": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
|
||||||
@ -2470,6 +2509,22 @@
|
|||||||
"punycode": "^2.1.1"
|
"punycode": "^2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ts-toolbelt": {
|
||||||
|
"version": "9.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-9.6.0.tgz",
|
||||||
|
"integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"ts-type": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-type/-/ts-type-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-cleRydCkBGBFQ4KAvLH0ARIkciduS745prkGVVxPGvcRGhMMoSJUB7gNR1ByKhFTEYrYRg2CsMRGYnqp+6op+g==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"tslib": ">=2",
|
||||||
|
"typedarray-dts": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"tslib": {
|
"tslib": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
||||||
@ -2483,6 +2538,11 @@
|
|||||||
"prelude-ls": "~1.1.2"
|
"prelude-ls": "~1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"typedarray-dts": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/typedarray-dts/-/typedarray-dts-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-Ka0DBegjuV9IPYFT1h0Qqk5U4pccebNIJCGl8C5uU7xtOs+jpJvKGAY4fHGK25hTmXZOEUl9Cnsg5cS6K/b5DA=="
|
||||||
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "4.9.4",
|
"version": "4.9.4",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"crlf-normalize": "^1.0.18",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"jsdom": "^21.0.0",
|
"jsdom": "^21.0.0",
|
||||||
"math-sum": "^2.0.0",
|
"math-sum": "^2.0.0",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
import proxy from 'superagent-proxy';
|
import proxy from 'superagent-proxy';
|
||||||
|
import { crlf, LF } from 'crlf-normalize';
|
||||||
import sleep from '../utils/sleep';
|
import sleep from '../utils/sleep';
|
||||||
import mathSum from 'math-sum';
|
import mathSum from 'math-sum';
|
||||||
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
|
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
|
||||||
@ -313,9 +314,9 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
if (body.compilationError === 'true') {
|
if (body.compilationError === 'true') {
|
||||||
return await end({
|
return await end({
|
||||||
id,
|
id,
|
||||||
error: 1,
|
error: true,
|
||||||
status: 'Compile Error',
|
status: 'Compile Error',
|
||||||
message: body['checkerStdoutAndStderr#1'],
|
message: crlf(body['checkerStdoutAndStderr#1'], LF),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const time = mathSum(
|
const time = mathSum(
|
||||||
@ -331,16 +332,52 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
) / 1024;
|
) / 1024;
|
||||||
await next({ test_id: body.testCount });
|
await next({ test_id: body.testCount });
|
||||||
if (body.waiting === 'true') continue;
|
if (body.waiting === 'true') continue;
|
||||||
|
|
||||||
|
const testCount = +body.testCount;
|
||||||
const status =
|
const status =
|
||||||
VERDICT[
|
VERDICT[
|
||||||
Object.keys(VERDICT).find(k => normalize(body.verdict).includes(k))
|
Object.keys(VERDICT).find(k => normalize(body.verdict).includes(k))
|
||||||
];
|
];
|
||||||
|
let tests: string[] = [];
|
||||||
|
|
||||||
|
for (let i = 1; i <= testCount; i++) {
|
||||||
|
let test_info = '';
|
||||||
|
let info_text =
|
||||||
|
VERDICT[
|
||||||
|
Object.keys(VERDICT).find(k =>
|
||||||
|
normalize(body[`verdict#${i}`]).includes(k)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
test_info += `<test num="${i}" info="${info_text}" time="${
|
||||||
|
body[`timeConsumed#${i}`]
|
||||||
|
}" memory="${body[`memoryConsumed#${i}`]}">`;
|
||||||
|
|
||||||
|
const parse = (id: string) => crlf(body[id], LF);
|
||||||
|
|
||||||
|
test_info += `<in>${parse(`input#${i}`)}</in>\n`;
|
||||||
|
test_info += `<out>${parse(`output#${i}`)}</out>\n`;
|
||||||
|
test_info += `<ans>${parse(`answer#${i}`)}</ans>\n`;
|
||||||
|
test_info += `<res>${parse(`checkerStdoutAndStderr#${i}`)}</res>\n`;
|
||||||
|
|
||||||
|
test_info += '</test>';
|
||||||
|
|
||||||
|
tests.push(test_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
const details =
|
||||||
|
'<div>' +
|
||||||
|
`<info-block>REMOTE_SUBMISSION_ID = ${id}\nVERDICT = ${status}</info-block>` +
|
||||||
|
`<tests>${tests.join('\n')}</tests>` +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
return await end({
|
return await end({
|
||||||
id,
|
id,
|
||||||
status,
|
status,
|
||||||
score: status === 'Accepted' ? 100 : 0,
|
score: status === 'Accepted' ? 100 : 0,
|
||||||
time,
|
time,
|
||||||
memory,
|
memory,
|
||||||
|
details,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,10 +67,11 @@ class AccountService {
|
|||||||
time: payload.time,
|
time: payload.time,
|
||||||
memory: payload.memory,
|
memory: payload.memory,
|
||||||
details:
|
details:
|
||||||
|
payload.details ||
|
||||||
'<div>' +
|
'<div>' +
|
||||||
`<info-block>ID = ${payload.id || 'None'}</info-block>` +
|
`<info-block>ID = ${payload.id || 'None'}</info-block>` +
|
||||||
`<info-block>VERDICT = ${payload.status}</info-block>` +
|
`<info-block>VERDICT = ${payload.status}</info-block>` +
|
||||||
'</div>',
|
'</div>',
|
||||||
}),
|
}),
|
||||||
judge_time,
|
judge_time,
|
||||||
});
|
});
|
||||||
|
@ -664,6 +664,11 @@ class JudgmentDetailsPrinter {
|
|||||||
echo '<pre class="bg-light p-3 rounded">', "\n";
|
echo '<pre class="bg-light p-3 rounded">', "\n";
|
||||||
$this->_print_c($node);
|
$this->_print_c($node);
|
||||||
echo "\n</pre>";
|
echo "\n</pre>";
|
||||||
|
} elseif ($node->nodeName == 'ans') {
|
||||||
|
echo '<h4 class="fs-6"><span>answer: </span></h4>';
|
||||||
|
echo '<pre class="bg-light p-3 rounded">', "\n";
|
||||||
|
$this->_print_c($node);
|
||||||
|
echo "\n</pre>";
|
||||||
} elseif ($node->nodeName == 'res') {
|
} elseif ($node->nodeName == 'res') {
|
||||||
echo '<h4 class="fs-6"><span>result: </span></h4>';
|
echo '<h4 class="fs-6"><span>result: </span></h4>';
|
||||||
echo '<pre class="bg-light p-3 rounded">', "\n";
|
echo '<pre class="bg-light p-3 rounded">', "\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user