feat(remote_judger/loj): include source code in result when fetching from archive
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-06 11:44:18 +08:00
parent 46592477c5
commit 050b4995ee
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 23 additions and 4 deletions

View File

@ -23,7 +23,8 @@ export interface IBasicProvider {
id: string,
next: NextFunction,
end: NextFunction,
problem_id?: string
problem_id: string,
result_show_source?: boolean
): Promise<void>;
}

View File

@ -1,11 +1,12 @@
import superagent from 'superagent';
import proxy from 'superagent-proxy';
import { stripVTControlCharacters } from 'util';
import { crlf, LF } from 'crlf-normalize';
import sleep from '../utils/sleep';
import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface';
import Logger from '../utils/logger';
import { normalize, VERDICT } from '../verdict';
import { crlf, LF } from 'crlf-normalize';
import htmlspecialchars from '../utils/htmlspecialchars';
proxy(superagent);
const logger = new Logger('remote/loj');
@ -285,7 +286,13 @@ export default class LibreojProvider implements IBasicProvider {
return user_id === submission_user_id;
}
async waitForSubmission(id: string, next, end, problem_id: string) {
async waitForSubmission(
id: string,
next,
end,
problem_id: string,
result_show_source = false
) {
if (!(await this.ensureLogin())) {
await end({
error: true,
@ -463,6 +470,16 @@ export default class LibreojProvider implements IBasicProvider {
`<p class="mb-0"><b>Verdict:</b> ${status}</p>` +
'</div>';
if (result_show_source) {
details +=
'<div class="border-bottom p-3">' +
'<div class="fw-bold mb-2">源代码</div>' +
`<pre><code class="language-${body.content.language} bg-light rounded p-3">` +
htmlspecialchars(parse(body.content.code)) +
'</code></pre>' +
'</div>';
}
// Samples
if (body.progress.samples) {
details += `<subtask title="Samples" info="${getSubtaskStatusDisplayText(

View File

@ -207,7 +207,8 @@ class VJudge {
config.remote_submission_id,
next,
end,
problem_id
problem_id,
true
);
} else {
return await end({