算法评测平台前端。
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

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) {
case 'submit-answer':
type = enums.ProblemType.AnswerSubmission;
param = null;
extraFile = 'static/uploads/answer/' + judge_state.code;
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
};
break;
}
const req = {
content: {
taskId: judge_state.task_id,
testData: problem.id.toString(),
type: type,
priority: priority,
param: param
},
extraFileLocation: extraFile
};
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
});
}