vjudge: support for adding solutions (#1030)

This commit is contained in:
BlackPanda authored and GitHub committed 2025-08-07 19:48:23 +01:00
1 parent ea20debc97
commit a255f53aa5
2 files changed
+3 -1

No files matched your search

+2 -1
View File
@@ -4,7 +4,7 @@ import { LangConfig, STATUS } from '@hydrooj/common';
import { import {
Context, db, DomainModel, JudgeResultCallbackContext, Logger, Context, db, DomainModel, JudgeResultCallbackContext, Logger,
ProblemModel, RecordModel, Service, SettingModel, ProblemModel, RecordModel, Service, SettingModel,
sleep, SystemModel, TaskModel, Time, yaml, sleep, SolutionModel, SystemModel, TaskModel, Time, yaml,
} from 'hydrooj'; } from 'hydrooj';
import { BasicProvider, IBasicProvider, RemoteAccount } from './interface'; import { BasicProvider, IBasicProvider, RemoteAccount } from './interface';
import providers from './providers/index'; import providers from './providers/index';
@@ -109,6 +109,7 @@ class AccountService {
for (const key in res.data) { for (const key in res.data) {
await ProblemModel.addTestdata(domainId, docId, key, res.data[key]); await ProblemModel.addTestdata(domainId, docId, key, res.data[key]);
} }
if (res.solution) await SolutionModel.add(domainId, docId, 1, res.solution);
logger.info(`${domainId}: problem ${docId}(${pid}) sync done -> ${targetPid}(${docId})`); logger.info(`${domainId}: problem ${docId}(${pid}) sync done -> ${targetPid}(${docId})`);
} finally { } finally {
delete syncing[`${domainId}/${pid}`]; delete syncing[`${domainId}/${pid}`];
+1
View File
@@ -35,6 +35,7 @@ export interface IBasicProvider {
tag: string[]; tag: string[];
content: string; content: string;
difficulty?: number; difficulty?: number;
solution?: string;
}>; }>;
entryProblemLists?: string[]; entryProblemLists?: string[];
listProblem: (page: number, resync: boolean, listId: string) => Promise<string[]>; listProblem: (page: number, resync: boolean, listId: string) => Promise<string[]>;