From eca992ac8752b3a0a60c2e4a6a4f832dae454aba Mon Sep 17 00:00:00 2001 From: t123yh Date: Sun, 27 Aug 2017 19:07:39 +0800 Subject: [PATCH] Change submission status when judge actually starts. --- models/judge_state.js | 11 +++++++---- modules/problem.js | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/models/judge_state.js b/models/judge_state.js index ee6efc6..8f45abb 100644 --- a/models/judge_state.js +++ b/models/judge_state.js @@ -97,12 +97,12 @@ class JudgeState extends Model { type: 0, type_info: 0, - pending: true, + pending: false, score: null, total_time: null, max_memory: null, - status: 'Waiting', + status: 'Unknown', result: null, task_id: randomstring.generate(10) }, val))); @@ -154,14 +154,14 @@ class JudgeState extends Model { let oldStatus = this.status; - this.status = 'Waiting'; + this.status = 'Unknown'; + this.pending = false; this.score = null; if (this.language) { // language is empty if it's a submit-answer problem this.total_time = null; this.max_memory = null; } - this.pending = true; this.result = {}; this.task_id = randomstring.generate(10); await this.save(); @@ -190,6 +190,9 @@ class JudgeState extends Model { try { await Judger.judge(this, this.problem, 1); + this.pending = true; + this.status = 'Waiting'; + await this.save(); } catch (err) { throw new ErrorMessage("无法开始评测。"); } diff --git a/modules/problem.js b/modules/problem.js index 7fa2509..8c73f9f 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -642,10 +642,10 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1 try { await Judger.judge(judge_state, problem, contest_id ? 3 : 2); - } catch (err) { - judge_state.status = "System Error"; - judge_state.pending = false; + judge_state.pending = true; + judge_state.status = 'Waiting'; await judge_state.save(); + } catch (err) { throw new ErrorMessage(`无法开始评测:${err.toString()}`); }