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(); this.db.sync();
}); });
}, },
lib(name) {
return require(`./libs/${name}`);
},
model(name) { model(name) {
return require(`./models/${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'; 'use strict';
let Sequelize = require('sequelize'); let Sequelize = require('sequelize');
const judger = require('../modules/judge');
let db = syzoj.db; let db = syzoj.db;
let User = syzoj.model('user'); let User = syzoj.model('user');
let Problem = syzoj.model('problem'); let Problem = syzoj.model('problem');
let Contest = syzoj.model('contest'); let Contest = syzoj.model('contest');
let Judger = syzoj.lib('judger');
let model = db.define('judge_state', { let model = db.define('judge_state', {
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
@ -232,7 +233,7 @@ class JudgeState extends Model {
await contest.newSubmission(this); 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) => { app.apiRouter.post('/api/v2/judge/compiled', async (req, res) => {
try { try {
if (req.get('Token') !== syzoj.config.judge_token) return res.status(403).send({ err: 'Incorrect token' }); 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 JudgeState = syzoj.model('judge_state');
let judge_state = await JudgeState.fromID(req.body.taskId); 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 ProblemTagMap = syzoj.model('problem_tag_map');
let Article = syzoj.model('article'); let Article = syzoj.model('article');
const judger = require('../modules/judge'); let Judger = syzoj.lib('judger');
app.get('/problems', async (req, res) => { app.get('/problems', async (req, res) => {
try { try {
@ -638,7 +638,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
await judge_state.updateRelatedInfo(true); await judge_state.updateRelatedInfo(true);
try { try {
await judger.judge(judge_state, contest_id ? 3 : 2); await Judger.judge(judge_state, contest_id ? 3 : 2);
} catch (err) { } catch (err) {
throw new ErrorMessage(`无法开始评测:${err.toString()}`); throw new ErrorMessage(`无法开始评测:${err.toString()}`);
} }

Loading…
Cancel
Save