judge: fix hosts dispose

This commit is contained in:
undefined committed 2023-01-30 12:38:59 +08:00
1 parent 31f107354c
commit d483531b0e
2 files changed
+7 -3

No files matched your search

+2 -2
View File
@@ -29,13 +29,13 @@ declare global {
}
}
global.onDestroy ||= [];
global.hosts ||= [];
global.hosts ||= {};
let exit = false;
const terminate = async () => {
log.info('正在保存数据');
try {
await Promise.all(global.hosts.map((f) => f.dispose?.()));
await Promise.all(Object.values(global.hosts).map((f) => f.dispose?.()));
process.exit(1);
} catch (e) {
if (exit) process.exit(1);
+5 -1
View File
@@ -51,7 +51,11 @@ export async function judge({
},
});
};
const usrAns = (answers[key]?.toString() || '').trim();
if (!answers[key]) {
report(STATUS.STATUS_WRONG_ANSWER, 0, 'No answer');
continue;
}
const usrAns = answers[key].toString().trim();
if (ansInfo instanceof Array) {
const fullScore = (+ansInfo[1]) || 0;
const stdAns = ansInfo[0];