mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
vjudge: codeforces: handle submission error
This commit is contained in:
1 parent
c6c4a80549
commit
72290bd5be
2 files changed
+15
-10
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/vjudge",
|
||||
"version": "1.5.0-next.7",
|
||||
"version": "1.5.0-next.8",
|
||||
"description": "Submit problems to remote oj",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -142,7 +142,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
async checkLogin() {
|
||||
await this.ensureBrowser();
|
||||
const page = await this.getPage();
|
||||
await page.goto(`${this.account.endpoint}/enter`, { waitUntil: 'networkidle2' });
|
||||
await page.goto(`${this.account.endpoint}/enter`, { waitUntil: 'networkidle2', timeout: 180000 });
|
||||
const html = await page.content();
|
||||
let cookies = await page.cookies();
|
||||
let c = 0;
|
||||
@@ -179,12 +179,10 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
}
|
||||
|
||||
get loggedIn() {
|
||||
return this.puppeteer
|
||||
? this.checkLogin().then(([, , loggedIn]) => loggedIn)
|
||||
: this.get('/enter').then(({ text: html }) => {
|
||||
if (html.includes('Login into Codeforces')) return false;
|
||||
return true;
|
||||
});
|
||||
return this.get('/enter').then(({ text: html }) => {
|
||||
if (html.includes('Login into Codeforces')) return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
async normalLogin() {
|
||||
@@ -360,7 +358,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
});
|
||||
}
|
||||
|
||||
async submitProblem(id: string, lang: string, code: string, info) {
|
||||
async submitProblem(id: string, lang: string, code: string, info, next, end) {
|
||||
const programTypeId = lang.includes('codeforces.') ? lang.split('codeforces.')[1] : '54';
|
||||
const comment = setting.langs[lang].comment;
|
||||
if (comment) {
|
||||
@@ -373,7 +371,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
? '/problemset/submit'
|
||||
: `/gym/${contestId}/submit`);
|
||||
// TODO check submit time to ensure submission
|
||||
await this.post(`/${type !== 'GYM' ? 'problemset' : `gym/${contestId}`}/submit?csrf_token=${csrf}`).send({
|
||||
const { text: submit } = await this.post(`/${type !== 'GYM' ? 'problemset' : `gym/${contestId}`}/submit?csrf_token=${csrf}`).send({
|
||||
csrf_token: csrf,
|
||||
action: 'submitSolutionFormSubmitted',
|
||||
programTypeId,
|
||||
@@ -391,6 +389,13 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
submittedProblemIndex: problemId,
|
||||
},
|
||||
});
|
||||
const { window: { document: statusDocument } } = new JSDOM(submit);
|
||||
const message = Array.from(statusDocument.querySelectorAll('.error'))
|
||||
.map((i) => i.textContent).join('').replace(/ /g, ' ').trim();
|
||||
if (message) {
|
||||
end({ status: STATUS.STATUS_COMPILE_ERROR, message });
|
||||
return null;
|
||||
}
|
||||
const { text: status } = await this.get(type !== 'GYM'
|
||||
? '/problemset/status?my=on'
|
||||
: `/gym/${contestId}/my`);
|
||||
|
||||
Reference in new issue
Block a user