Browse Source

Merge branch 'judge-v3' of github.com:syzoj/syzoj into judge-v3

pull/6/head
t123yh 7 years ago
parent
commit
50f3d0bf14
  1. 3
      app.js
  2. 0
      libs/enums.js
  3. 0
      libs/judger.js
  4. 5
      models/judge_state.js
  5. 2
      modules/api_v2.js
  6. 4
      modules/problem.js

3
app.js

@ -112,6 +112,9 @@ global.syzoj = {
this.db.sync();
});
},
lib(name) {
return require(`./libs/${name}`);
},
model(name) {
return require(`./models/${name}`);
},

0
modules/enums.js → libs/enums.js

0
modules/judge.js → libs/judger.js

5
models/judge_state.js

@ -20,13 +20,14 @@
'use strict';
let Sequelize = require('sequelize');
const judger = require('../modules/judge');
let db = syzoj.db;
let User = syzoj.model('user');
let Problem = syzoj.model('problem');
let Contest = syzoj.model('contest');
let Judger = syzoj.lib('judger');
let model = db.define('judge_state', {
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
@ -232,7 +233,7 @@ class JudgeState extends Model {
await contest.newSubmission(this);
}
await judger.judge(this, 1);
await Judger.judge(this, 1);
});
}

2
modules/api_v2.js

@ -158,7 +158,7 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
app.apiRouter.post('/api/v2/judge/compiled', async (req, res) => {
try {
if (req.get('Token') !== syzoj.config.judge_token) return res.status(403).send({ err: 'Incorrect token' });
const data = req.body;
let data = req.body;
let JudgeState = syzoj.model('judge_state');
let judge_state = await JudgeState.fromID(req.body.taskId);

4
modules/problem.js

@ -28,7 +28,7 @@ let ProblemTag = syzoj.model('problem_tag');
let ProblemTagMap = syzoj.model('problem_tag_map');
let Article = syzoj.model('article');
const judger = require('../modules/judge');
let Judger = syzoj.lib('judger');
app.get('/problems', async (req, res) => {
try {
@ -638,7 +638,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
await judge_state.updateRelatedInfo(true);
try {
await judger.judge(judge_state, contest_id ? 3 : 2);
await Judger.judge(judge_state, contest_id ? 3 : 2);
} catch (err) {
throw new ErrorMessage(`无法开始评测:${err.toString()}`);
}

Loading…
Cancel
Save