You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

8 years ago
const enums = require('./enums'),
rp = require('request-promise'),
url = require('url');
const util = require('util');
module.exports.judge = async function (judge_state, problem, priority) {
let type, param, extraFile = null;
switch (problem.type) {
8 years ago
case 'submit-answer':
type = enums.ProblemType.AnswerSubmission;
param = null;
extraFile = 'static/uploads/answer/' + judge_state.code;
8 years ago
break;
case 'interaction':
type = enums.ProblemType.Interaction;
break;
default:
type = enums.ProblemType.Standard;
param = {
language: judge_state.language,
code: judge_state.code,
timeLimit: problem.time_limit,
memoryLimit: problem.memory_limit,
fileIOInput: problem.file_io ? problem.file_io_input_name : null,
fileIOOutput: problem.file_io ? problem.file_io_output_name : null
8 years ago
};
break;
}
const req = {
content: {
7 years ago
taskId: judge_state.task_id,
testData: problem.id.toString(),
type: type,
priority: priority,
param: param
},
extraFileLocation: extraFile
8 years ago
};
await rp(url.resolve(syzoj.config.judge_server_addr, "/daemon/task"), {
method: 'PUT',
body: req,
headers: {
Token: syzoj.config.judge_token
},
json: true,
simple: true
});
}