用户登录后方可提交题目,用户点击提交按钮后,代码将会通过ajax post提交给后台,后台ojsite web服务器向judger提交判题任务,并向客户端浏览器返回true代表提交判题任务成功。前端若是收到添加判题任务成功的返回信息则开始每隔1秒向ojsite服务器查询一次判题结果,若是查询到的结果为TA(Task Added),则继续查询,若为其他状态,则在信息提示区显示相关的提示信息。RE代表Runtime Error(运行时错误),MLE为Out of Memory(内存使用过量),TLE为Out of Time(执行超时),OLE为Output Limit(输出内容超出范围),PSF为Syscal Forbidden(非法系统调用),CE为Compile Error(编译错误),AC为Accept(判题通过),其他状态为Unknown(未知)。
$.ajax({
url: $(this).attr("action"),
method: "post",
data: {"pid":pid, "language":language, "ptype":ptype, "code":code},
dataType: "json",
success: function(json){
console.log(json);
update_status("black","","icon-spin4 animate-spin","Waiting...");
if (json.result) {
// get status after 1s
var tc = window.setInterval(function(){
$.ajax({
url: $("form.submition").attr("get-status"),
method: "get",
data: {"sbid":json.id},
dataType: "json",
success: function(json){
console.log(json);
if (json.result) {
// if get result clearInterval
if (json.status!="TA"){
window.clearInterval(tc);
if (json.status == "AC") {
update_status("green","","icon-ok","Accept");
} else if(json.status == "RE"){
update_status("red","","icon-cancel","Runtime Error");
}else if(json.status == "MLE"){
update_status("red","","icon-cancel","Out Of Memory");
}else if(json.status == "TLE"){
update_status("red","","icon-cancel","Out Of Time");
}else if(json.status == "OLE"){
update_status("red","","icon-cancel","Output Limit");
}else if(json.status == "PSF"){
update_status("red","","icon-cancel",
"Syscal Forbidden");
}else if (json.status == "CE") {
update_status("red","","icon-cancel","Compile Error");
}else{
update_status("gray","","icon-cancel","Unknown");
};
}else{
update_status("black","",
"icon-spin4 animate-spin","Waiting...");
}
};
}
});
}, 1000);
};
}
});
用户会在题目详情页面提交了代码答案后立即能够看到判题结果。但是不允许看到错误的详细提示。错误的详细提示会记录于数据库,对于公开题目用户可以直接在个人中心中看到编译详情或错误详情。