Browse Source

Change submission status when judge actually starts.

pull/6/head
t123yh 7 years ago
parent
commit
eca992ac87
  1. 11
      models/judge_state.js
  2. 6
      modules/problem.js

11
models/judge_state.js

@ -97,12 +97,12 @@ class JudgeState extends Model {
type: 0, type: 0,
type_info: 0, type_info: 0,
pending: true, pending: false,
score: null, score: null,
total_time: null, total_time: null,
max_memory: null, max_memory: null,
status: 'Waiting', status: 'Unknown',
result: null, result: null,
task_id: randomstring.generate(10) task_id: randomstring.generate(10)
}, val))); }, val)));
@ -154,14 +154,14 @@ class JudgeState extends Model {
let oldStatus = this.status; let oldStatus = this.status;
this.status = 'Waiting'; this.status = 'Unknown';
this.pending = false;
this.score = null; this.score = null;
if (this.language) { if (this.language) {
// language is empty if it's a submit-answer problem // language is empty if it's a submit-answer problem
this.total_time = null; this.total_time = null;
this.max_memory = null; this.max_memory = null;
} }
this.pending = true;
this.result = {}; this.result = {};
this.task_id = randomstring.generate(10); this.task_id = randomstring.generate(10);
await this.save(); await this.save();
@ -190,6 +190,9 @@ class JudgeState extends Model {
try { try {
await Judger.judge(this, this.problem, 1); await Judger.judge(this, this.problem, 1);
this.pending = true;
this.status = 'Waiting';
await this.save();
} catch (err) { } catch (err) {
throw new ErrorMessage("无法开始评测。"); throw new ErrorMessage("无法开始评测。");
} }

6
modules/problem.js

@ -642,10 +642,10 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
try { try {
await Judger.judge(judge_state, problem, contest_id ? 3 : 2); await Judger.judge(judge_state, problem, contest_id ? 3 : 2);
} catch (err) { judge_state.pending = true;
judge_state.status = "System Error"; judge_state.status = 'Waiting';
judge_state.pending = false;
await judge_state.save(); await judge_state.save();
} catch (err) {
throw new ErrorMessage(`无法开始评测:${err.toString()}`); throw new ErrorMessage(`无法开始评测:${err.toString()}`);
} }

Loading…
Cancel
Save