mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-12-18 01:31:54 +00:00
fix(remote_judger/codeforces): fetch submission
This commit is contained in:
parent
a734c829b9
commit
0098031da1
@ -341,9 +341,12 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
this.csrf = document
|
this.csrf = document
|
||||||
.querySelector('meta[name="X-Csrf-Token"]')
|
.querySelector('meta[name="X-Csrf-Token"]')
|
||||||
.getAttribute('content');
|
.getAttribute('content');
|
||||||
return document
|
|
||||||
|
const submission = document
|
||||||
.querySelector('[data-submission-id]')
|
.querySelector('[data-submission-id]')
|
||||||
.getAttribute('data-submission-id');
|
.getAttribute('data-submission-id');
|
||||||
|
|
||||||
|
return type !== 'GYM' ? submission : `${contestId}#${submission}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ensureIsOwnSubmission(id: string) {
|
async ensureIsOwnSubmission(id: string) {
|
||||||
@ -354,21 +357,30 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
let count = 0;
|
let count = 0;
|
||||||
let fail = 0;
|
let fail = 0;
|
||||||
|
|
||||||
|
const contestId = id.includes('#') ? id.split('#')[0] : null;
|
||||||
|
const submissionId = id.includes('#') ? id.split('#')[1] : id;
|
||||||
|
|
||||||
while (count < 360 && fail < 60) {
|
while (count < 360 && fail < 60) {
|
||||||
count++;
|
count++;
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { body } = await this.post('/data/submitSource')
|
const { body } = await this.post('/data/submitSource')
|
||||||
|
.set(
|
||||||
|
'referer',
|
||||||
|
contestId
|
||||||
|
? `https://codeforces.com/gym/${contestId}/my`
|
||||||
|
: 'https://codeforces.com/problemset/status?my=on'
|
||||||
|
)
|
||||||
.send({
|
.send({
|
||||||
csrf_token: this.csrf,
|
csrf_token: this.csrf,
|
||||||
submissionId: id,
|
submissionId: submissionId,
|
||||||
})
|
})
|
||||||
.retry(3);
|
.retry(3);
|
||||||
|
|
||||||
if (body.compilationError === 'true') {
|
if (body.compilationError === 'true') {
|
||||||
return await end({
|
return await end({
|
||||||
id,
|
id: submissionId,
|
||||||
error: true,
|
error: true,
|
||||||
status: 'Compile Error',
|
status: 'Compile Error',
|
||||||
message: crlf(body['checkerStdoutAndStderr#1'], LF),
|
message: crlf(body['checkerStdoutAndStderr#1'], LF),
|
||||||
@ -439,7 +451,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
Object.entries({
|
Object.entries({
|
||||||
比赛: stripHtml(body.contestName).result,
|
比赛: stripHtml(body.contestName).result,
|
||||||
题目: stripHtml(body.problemName).result,
|
题目: stripHtml(body.problemName).result,
|
||||||
提交记录: `<a href="https://codeforces.com${body.href}">${id}</a>`,
|
提交记录: `<a href="https://codeforces.com${body.href}">${submissionId}</a>`,
|
||||||
账号: `<a href="https://codeforces.com/profile/${remote_handle}">${remote_handle}</a>`,
|
账号: `<a href="https://codeforces.com/profile/${remote_handle}">${remote_handle}</a>`,
|
||||||
状态: stripHtml(body.verdict).result,
|
状态: stripHtml(body.verdict).result,
|
||||||
})
|
})
|
||||||
@ -453,7 +465,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
return await end({
|
return await end({
|
||||||
id,
|
id: submissionId,
|
||||||
status,
|
status,
|
||||||
score: status === 'Accepted' ? 100 : 0,
|
score: status === 'Accepted' ? 100 : 0,
|
||||||
time,
|
time,
|
||||||
@ -469,7 +481,7 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return await end({
|
return await end({
|
||||||
id,
|
id: submissionId,
|
||||||
error: true,
|
error: true,
|
||||||
status: 'Judgment Failed',
|
status: 'Judgment Failed',
|
||||||
message: 'Failed to fetch submission details.',
|
message: 'Failed to fetch submission details.',
|
||||||
|
Loading…
Reference in New Issue
Block a user