judge: objective: handle zero-question problem

pull/462/head
undefined 2 years ago
parent 3371f39ef4
commit 700de4fc9d

@ -2,6 +2,7 @@ import assert from 'assert';
import { readFile } from 'fs-extra'; import { readFile } from 'fs-extra';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { STATUS } from '@hydrooj/utils/lib/status'; import { STATUS } from '@hydrooj/utils/lib/status';
import { FormatError } from '../error';
import { Context } from './interface'; import { Context } from './interface';
export async function judge({ export async function judge({
@ -29,6 +30,7 @@ export async function judge({
} }
let totalScore = 0; let totalScore = 0;
let totalStatus = 0; let totalStatus = 0;
if (!Object.keys(answers).length) throw new FormatError('Invalid standard answer.');
for (const key in config.answers) { for (const key in config.answers) {
const [subtaskId, caseId] = key.split('-').map(Number); const [subtaskId, caseId] = key.split('-').map(Number);
const ansInfo = config.answers[key] as [string | string[], number]; const ansInfo = config.answers[key] as [string | string[], number];

Loading…
Cancel
Save