Browse Source

Upload data for answer submission problems and fix some horrible mistakes

pull/6/head
hewenyang 7 years ago
parent
commit
1244a8d7a1
  1. 1
      config-example.json
  2. 14
      libs/judger.js

1
config-example.json

@ -167,5 +167,6 @@
], ],
"session_secret": "233", "session_secret": "233",
"rabbitMQ": "amqp://localhost/", "rabbitMQ": "amqp://localhost/",
"judge_token": "233",
"email_jwt_secret": "test" "email_jwt_secret": "test"
} }

14
libs/judger.js

@ -28,7 +28,6 @@ async function connect () {
}); });
amqpConsumeChannel = await amqpConnection.createChannel(); amqpConsumeChannel = await amqpConnection.createChannel();
amqpConsumeChannel.prefetch(1); amqpConsumeChannel.prefetch(1);
winston.debug('Winston test');
amqpConsumeChannel.consume('result', async (msg) => { amqpConsumeChannel.consume('result', async (msg) => {
(async(msg) => { (async(msg) => {
const data = msgPack.decode(msg.content); const data = msgPack.decode(msg.content);
@ -99,12 +98,13 @@ async function connect () {
} }
module.exports.judge = async function (judge_state, problem, priority) { module.exports.judge = async function (judge_state, problem, priority) {
let type, param, extraFile = null; let type, param, extraData = null;
switch (problem.type) { switch (problem.type) {
case 'submit-answer': case 'submit-answer':
type = enums.ProblemType.AnswerSubmission; type = enums.ProblemType.AnswerSubmission;
param = null; param = null;
extraFile = 'static/uploads/answer/' + judge_state.code; let fs = Promise.promisifyAll(require('fs-extra'));
extraData = await fs.readFileAsync(syzoj.model('file').resolvePath('answer', judge_state.code));
break; break;
case 'interaction': case 'interaction':
type = enums.ProblemType.Interaction; type = enums.ProblemType.Interaction;
@ -128,19 +128,15 @@ module.exports.judge = async function (judge_state, problem, priority) {
break; break;
} }
const req = { const content = {
content: {
taskId: judge_state.task_id, taskId: judge_state.task_id,
testData: problem.id.toString(), testData: problem.id.toString(),
type: type, type: type,
priority: priority, priority: priority,
param: param param: param
},
extraFileLocation: extraFile
}; };
// TODO: parse extraFileLocation amqpSendChannel.sendToQueue('judge', msgPack.encode({ content: content, extraData: extraData }), { priority: priority });
amqpSendChannel.sendToQueue('judge', msgPack.encode({ content: req.content, extraData: null }), { priority: priority });
} }
connect(); connect();

Loading…
Cancel
Save