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_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("无法开始评测。");
}

6
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()}`);
}

Loading…
Cancel
Save