mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-25 08:58:41 +00:00
feat(remote_judger/luogu): fetch submission from archive
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
3b109b96b2
commit
806b8e880c
@ -19,6 +19,7 @@ export interface IBasicProvider {
|
||||
next: NextFunction,
|
||||
end: NextFunction
|
||||
): Promise<string | void>;
|
||||
ensureIsOwnSubmission(id: string): Promise<boolean | void>;
|
||||
waitForSubmission(
|
||||
id: string,
|
||||
next: NextFunction,
|
||||
|
@ -244,6 +244,10 @@ export default class AtcoderProvider implements IBasicProvider {
|
||||
.getAttribute('data-id');
|
||||
}
|
||||
|
||||
async ensureIsOwnSubmission(id: string) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
async waitForSubmission(id: string, next, end, problem_id: string) {
|
||||
let count = 0;
|
||||
let fail = 0;
|
||||
|
@ -344,6 +344,10 @@ export default class CodeforcesProvider implements IBasicProvider {
|
||||
.getAttribute('data-submission-id');
|
||||
}
|
||||
|
||||
async ensureIsOwnSubmission(id: string) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
async waitForSubmission(id: string, next, end) {
|
||||
let count = 0;
|
||||
let fail = 0;
|
||||
|
@ -250,7 +250,26 @@ export default class LuoguProvider implements IBasicProvider {
|
||||
return result.body.rid;
|
||||
}
|
||||
|
||||
async waitForSubmission(id: string, next, end) {
|
||||
async ensureIsOwnSubmission(id: string) {
|
||||
const { body } = await this.safeGet(`/record/${id}?_contentOnly=1`);
|
||||
|
||||
const current_uid = body.currentUser?.uid;
|
||||
const submission_uid = body.currentData.record?.user.uid;
|
||||
|
||||
return current_uid && submission_uid && current_uid === submission_uid;
|
||||
}
|
||||
|
||||
async waitForSubmission(id: string, next, end, problem_id: string) {
|
||||
if (!(await this.ensureLogin())) {
|
||||
await end({
|
||||
error: true,
|
||||
status: 'Judgment Failed',
|
||||
message: 'Login failed',
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
let fail = 0;
|
||||
let count = 0;
|
||||
|
||||
@ -262,6 +281,24 @@ export default class LuoguProvider implements IBasicProvider {
|
||||
const { body } = await this.safeGet(`/record/${id}?_contentOnly=1`);
|
||||
const data = body.currentData.record;
|
||||
|
||||
if (!data) {
|
||||
return await end({
|
||||
error: true,
|
||||
id: `R${id}`,
|
||||
status: 'Judgment Failed',
|
||||
message: 'Failed to fetch submission details.',
|
||||
});
|
||||
}
|
||||
|
||||
if (data.problem.pid != problem_id) {
|
||||
return await end({
|
||||
id,
|
||||
error: true,
|
||||
status: 'Judgment Failed',
|
||||
message: 'Submission does not match current problem.',
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
data.detail.compileResult &&
|
||||
data.detail.compileResult.success === false
|
||||
|
@ -206,6 +206,10 @@ export default class UOJProvider implements IBasicProvider {
|
||||
.innerHTML.split('#')[1];
|
||||
}
|
||||
|
||||
async ensureIsOwnSubmission(id: string) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
async waitForSubmission(id: string, next, end) {
|
||||
let count = 0;
|
||||
let fail = 0;
|
||||
|
@ -49,7 +49,7 @@ class UOJRemoteProblem {
|
||||
'short_name' => '洛谷',
|
||||
'url' => 'https://www.luogu.com.cn',
|
||||
'languages' => ['C', 'C++98', 'C++11', 'C++', 'C++17', 'C++20', 'Python3', 'Java8', 'Pascal'],
|
||||
'submit_type' => ['my'],
|
||||
'submit_type' => ['my', 'archive'],
|
||||
],
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user