vjudge: codeforces: fix

This commit is contained in:
undefined committed 2023-02-05 18:44:05 +08:00
1 parent 1124ed9506
commit 018257f2b8
1 file changed
+6 -14
+6 -14
View File
@@ -279,31 +279,23 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
else if (comment instanceof Array) code = `${comment[0]} ${msg} ${comment[1]}\n${code}`; else if (comment instanceof Array) code = `${comment[0]} ${msg} ${comment[1]}\n${code}`;
} }
const [type, contestId, problemId] = parseProblemId(id); const [type, contestId, problemId] = parseProblemId(id);
const [csrf, ftaa, bfaa] = await this.getCsrfToken(type !== 'GYM'
? '/problemset/submit'
: `/gym/${contestId}/submit`);
// TODO check submit time to ensure submission
const endpoint = type === 'GYM' const endpoint = type === 'GYM'
? `/gym/${contestId}/submit?csrf_token=${csrf}` ? `/gym/${contestId}/submit`
: `/problemset/submit/${contestId}/${problemId}?csrf_token=${csrf}`; : `/problemset/submit/${contestId}/${problemId}`;
const { text: submit } = await this.post(endpoint).send({ const [csrf, ftaa, bfaa] = await this.getCsrfToken(endpoint);
// TODO check submit time to ensure submission
const { text: submit } = await this.post(`${endpoint}?csrf_token=${csrf}`).send({
csrf_token: csrf, csrf_token: csrf,
action: 'submitSolutionFormSubmitted', action: 'submitSolutionFormSubmitted',
programTypeId, programTypeId,
source: code, source: code,
tabsize: 4, tabSize: 4,
sourceFile: '', sourceFile: '',
ftaa, ftaa,
bfaa, bfaa,
_tta: this.tta(this.getCookie('39ce7')), _tta: this.tta(this.getCookie('39ce7')),
...(type !== 'GYM')
? {
submittedProblemCode: contestId + problemId,
sourceCodeConfirmed: true,
} : {
contestId, contestId,
submittedProblemIndex: problemId, submittedProblemIndex: problemId,
},
}); });
const { window: { document: statusDocument } } = new JSDOM(submit); const { window: { document: statusDocument } } = new JSDOM(submit);
const message = Array.from(statusDocument.querySelectorAll('.error')) const message = Array.from(statusDocument.querySelectorAll('.error'))