Browse Source

update: 比赛加分逻辑更改。

pull/14/head
zjz1993 5 years ago
parent
commit
78dc2519bc
  1. 15
      libs/judger.js

15
libs/judger.js

@ -5,6 +5,7 @@ const msgPack = require('msgpack-lite');
const fs = require('fs-extra');
const interface = require('./judger_interfaces');
const judgeResult = require('./judgeResult');
let Problem = syzoj.model('problem');
const judgeStateCache = new Map();
const progressPusher = require('../modules/socketio');
@ -158,7 +159,6 @@ async function connect() {
}
const result = msgPack.decode(payload);
console.log(result);
winston.verbose('Received report for task ' + result.taskId);
const judge_state = await JudgeState.findOne({
@ -171,9 +171,18 @@ async function connect() {
const convertedResult = judgeResult.convertResult(result.taskId, result.progress);
winston.verbose('Reporting report finished: ' + result.taskId);
progressPusher.cleanupProgress(result.taskId);
console.log(convertedResult);
if (!judge_state) return;
judge_state.score = convertedResult.score;
const problemId = judge_state.problem_id;
let problemQuery = await Problem.createQueryBuilder();
const problemInfo = await problemQuery.where("id = :id", { id: problemId }).getOne();
const problem_time_limit = problemInfo.time_limit;
if (judge_state.type_info && convertedResult.statusString === 'Accepted' && convertedResult.time < problem_time_limit * 0.9) {
const beyondTime = problem_time_limit - convertedResult.time;
const extraScore = (beyondTime / problem_time_limit).toString().slice(0,3)*100;
judge_state.score = convertedResult.score + extraScore;
} else {
judge_state.score = convertedResult.score;
}
judge_state.pending = false;
judge_state.status = convertedResult.statusString;
judge_state.total_time = convertedResult.time;

Loading…
Cancel
Save