judge: config.template

This commit is contained in:
undefined committed 2021-06-20 14:05:59 +08:00
1 parent b2fe14ffe7
commit ab58505b9d
7 files changed
+85 -48

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.8.10",
"version": "2.8.11",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
+7 -1
View File
@@ -2,7 +2,7 @@ import Queue from 'p-queue';
import path from 'path';
import fs from 'fs-extra';
import * as STATUS from '../status';
import { SystemError } from '../error';
import { CompileError, SystemError } from '../error';
import { parseFilename } from '../utils';
import { run } from '../sandbox';
import compile from '../compile';
@@ -18,6 +18,12 @@ const Score = {
function judgeCase(c, sid) {
return async (ctx, ctxSubtask) => {
if (ctx.config.template) {
if (ctx.config.template[ctx.lang]) {
const tpl = ctx.config.template[ctx.lang];
ctx.code = tpl[0] + ctx.code + tpl[1];
} else throw new CompileError('Language not supported by provided templates');
}
if ((ctxSubtask.subtask.type === 'min' && !ctxSubtask.score)
|| (ctxSubtask.subtask.type === 'max' && ctxSubtask.score === ctxSubtask.subtask.score)
|| (ctxSubtask.subtask.if && ctx.failed[sid])