Compare commits

...

2 Commits

Author SHA1 Message Date
d897a27801
chore(remote_judger/codeforces): include source code in result
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-08 16:02:44 +08:00
36ff691a04
feat(remote_judger): submitProblem status report 2023-04-08 15:45:35 +08:00
6 changed files with 35 additions and 4 deletions

View File

@ -205,6 +205,8 @@ export default class AtcoderProvider implements IBasicProvider {
`(S2OJ Submission #${submissionId})` `(S2OJ Submission #${submissionId})`
); );
await next({ status: 'Submitting to AtCoder...' });
// TODO: check submit time to ensure submission // TODO: check submit time to ensure submission
const res = await this.post(`/contests/${contestId}/submit`).send({ const res = await this.post(`/contests/${contestId}/submit`).send({
csrf_token: csrf, csrf_token: csrf,
@ -227,6 +229,8 @@ export default class AtcoderProvider implements IBasicProvider {
this.cookie = res.header['set-cookie']; this.cookie = res.header['set-cookie'];
} }
await next({ status: 'Submitted to AtCoder' });
const { text: status, header: status_header } = await this.get( const { text: status, header: status_header } = await this.get(
`/contests/${contestId}/submissions/me` `/contests/${contestId}/submissions/me`
).retry(3); ).retry(3);
@ -280,7 +284,7 @@ export default class AtcoderProvider implements IBasicProvider {
statusElem.title === 'Waiting for Re-judging' || statusElem.title === 'Waiting for Re-judging' ||
['WJ', 'WR'].includes(statusElem.innerHTML.trim()) ['WJ', 'WR'].includes(statusElem.innerHTML.trim())
) { ) {
await next({ test_id: 0 }); await next({ status: '[AtCoder] Waiting for Judging' });
continue; continue;
} }

View File

@ -277,6 +277,8 @@ export default class CodeforcesProvider implements IBasicProvider {
`(S2OJ Submission #${submissionId})` `(S2OJ Submission #${submissionId})`
); );
await next({ status: 'Submitting to Codeforces...' });
// TODO: check submit time to ensure submission // TODO: check submit time to ensure submission
const { text: submit, error } = await this.post( const { text: submit, error } = await this.post(
`/${ `/${
@ -328,6 +330,8 @@ export default class CodeforcesProvider implements IBasicProvider {
return null; return null;
} }
await next({ status: 'Submitted to Codeforces' });
const { text: status } = await this.get( const { text: status } = await this.get(
type !== 'GYM' ? '/problemset/status?my=on' : `/gym/${contestId}/my` type !== 'GYM' ? '/problemset/status?my=on' : `/gym/${contestId}/my`
).retry(3); ).retry(3);
@ -350,9 +354,9 @@ export default class CodeforcesProvider implements IBasicProvider {
let count = 0; let count = 0;
let fail = 0; let fail = 0;
while (count < 180 && fail < 10) { while (count < 360 && fail < 60) {
count++; count++;
await sleep(1000); await sleep(500);
try { try {
const { body } = await this.post('/data/submitSource') const { body } = await this.post('/data/submitSource')
@ -386,6 +390,16 @@ export default class CodeforcesProvider implements IBasicProvider {
if (body.waiting === 'true') continue; if (body.waiting === 'true') continue;
let files = [];
if (body?.source) {
files.push({
name: 'answer.code',
content: body.source,
lang: '/',
});
}
const testCount = +body.testCount; const testCount = +body.testCount;
const status = const status =
VERDICT[ VERDICT[
@ -446,6 +460,7 @@ export default class CodeforcesProvider implements IBasicProvider {
time, time,
memory, memory,
details, details,
result: { files },
}); });
} catch (e) { } catch (e) {
logger.error(e); logger.error(e);

View File

@ -249,6 +249,8 @@ export default class LibreojProvider implements IBasicProvider {
`(S2OJ Submission #${submissionId})` `(S2OJ Submission #${submissionId})`
); );
await next({ status: 'Submitting to LibreOJ...' });
const { body, error } = await this.post('/submission/submit').send({ const { body, error } = await this.post('/submission/submit').send({
problemId: id, problemId: id,
content: { content: {
@ -268,6 +270,8 @@ export default class LibreojProvider implements IBasicProvider {
return null; return null;
} }
await next({ status: 'Submitted to LibreOJ' });
return body.submissionId; return body.submissionId;
} }
@ -345,7 +349,7 @@ export default class LibreojProvider implements IBasicProvider {
} }
await next({ await next({
status: `${body.progress.progressType}`, status: `[LibreOJ] ${body.progress.progressType}`,
}); });
if (body.progress.progressType !== 'Finished') { if (body.progress.progressType !== 'Finished') {

View File

@ -319,6 +319,8 @@ export default class LuoguProvider implements IBasicProvider {
code = `${comment[0]} ${msg} ${comment[1]}\n${code}`; code = `${comment[0]} ${msg} ${comment[1]}\n${code}`;
} }
await next({ status: 'Submitting to Luogu...' });
if (this.account.type == 'luogu-api') { if (this.account.type == 'luogu-api') {
const result = await this.post('/judge/problem').send({ const result = await this.post('/judge/problem').send({
pid: id, pid: id,

View File

@ -200,6 +200,8 @@ export default class QOJProvider extends UOJProvider implements IBasicProvider {
code = `${comment[0]} ${msg} ${comment[1]}\n${code}`; code = `${comment[0]} ${msg} ${comment[1]}\n${code}`;
} }
await next({ status: 'Submitting to QOJ...' });
const _token = await this.getCsrfToken(`/problem/${id}`); const _token = await this.getCsrfToken(`/problem/${id}`);
const { text } = await this.post(`/problem/${id}`).send({ const { text } = await this.post(`/problem/${id}`).send({
_token, _token,

View File

@ -217,6 +217,8 @@ export default class UOJProvider implements IBasicProvider {
code = `${comment[0]} ${msg} ${comment[1]}\n${code}`; code = `${comment[0]} ${msg} ${comment[1]}\n${code}`;
} }
await next({ status: 'Submitting to UniversalOJ...' });
const _token = await this.getCsrfToken(`/problem/${id}`); const _token = await this.getCsrfToken(`/problem/${id}`);
const { text } = await this.post(`/problem/${id}`).send({ const { text } = await this.post(`/problem/${id}`).send({
_token, _token,
@ -228,6 +230,8 @@ export default class UOJProvider implements IBasicProvider {
if (!text.includes('我的提交记录')) throw new Error('Submit failed'); if (!text.includes('我的提交记录')) throw new Error('Submit failed');
await next({ status: 'Submitted to UniversalOJ' });
const { text: status } = await this.get( const { text: status } = await this.get(
`/submissions?problem_id=${id}&submitter=${this.account.handle}` `/submissions?problem_id=${id}&submitter=${this.account.handle}`
); );