@ -11,11 +11,14 @@ $(function(){
var title = $ ( '#program-title' ) . val ( ) ;
var title = $ ( '#program-title' ) . val ( ) ;
if ( ! src ) {
if ( ! src ) {
alert ( '请输入正确的代码' ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>请输入正确的代码!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
return false ;
return false ;
}
}
if ( ! title ) {
if ( ! title ) {
alert ( '请输入标题' ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>请输入标题!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
return false ;
return false ;
}
}
return true ;
return true ;
@ -33,31 +36,6 @@ $(function(){
$ ( '#test-program-btn' ) . show ( ) ;
$ ( '#test-program-btn' ) . show ( ) ;
return ;
return ;
}
}
/ *
$ . post (
'/student_work/program_test_ex' ,
{ homework : homework _id , student _work _id : student _work _id , src : src , title : title , is _test : is _test } ,
function ( data , status ) {
tested = true ;
console . log ( data ) ;
if ( data . index <= 0 ) {
data . index = $ ( '.ProResultTop' ) . length + 1 ;
}
if ( typeof cb == 'function' ) { cb ( data ) ; return ; }
var html = bt ( 't:result-list' , data ) ;
$ ( '.ProResult' ) . prepend ( html ) ;
if ( data . status == 0 && is _test != 'true' ) {
var r = confirm ( "答题正确,是否立刻提交?" ) ;
if ( r ) {
$ ( ".HomeWorkCon form" ) . submit ( ) ;
}
}
}
) ;
* /
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
var test _post = function ( i , testid ) {
var test _post = function ( i , testid ) {
$ . post (
$ . post (
@ -66,6 +44,22 @@ $(function(){
src : src , title : title , is _test : is _test , tIndex : i ,
src : src , title : title , is _test : is _test , tIndex : i ,
testid : testid } ,
testid : testid } ,
function ( data , status ) {
function ( data , status ) {
if ( data . status == - 4 || data . status == - 5 ) {
//弹框
var root _path = getRootPath ( ) ;
var forums _1 _path = root _path + "/forums/1"
var htmlvalue = "</br><div style='width:430px;text-align:center;margin:0 auto' >您的程序引发了不知名异常,请在公共贴吧提交您的代码进行意见反馈,我们处理后会立即联系您,谢谢!</div><div style='width:550px;text-align:center'><a target='_Blank' href=" + forums _1 _path + ">点我进入反馈页面</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
$ ( '#test-program-btn' ) . show ( ) ;
return ;
}
else if ( data . status == - 3 ) {
var htmlvalue = "</br><div style='width:550px;text-align:center'>对不起,服务器繁忙请稍后再试!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
$ ( '#test-program-btn' ) . show ( ) ;
return ;
}
var tSeq = data . tseq ;
var tSeq = data . tseq ;
var tCount = data . tcount ;
var tCount = data . tcount ;
console . log ( "tSeq=" + tSeq ) ;
console . log ( "tSeq=" + tSeq ) ;
@ -81,10 +75,8 @@ $(function(){
if ( data . status == 0 && is _test != 'true' ) {
if ( data . status == 0 && is _test != 'true' ) {
if ( typeof cb == 'function' ) { cb ( data ) ; $ ( '#test-program-btn' ) . show ( ) ; return ; }
if ( typeof cb == 'function' ) { cb ( data ) ; $ ( '#test-program-btn' ) . show ( ) ; return ; }
var r = confirm ( "答题正确,是否立刻提交?" ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>答题正确,是否立刻提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>" ;
if ( r ) {
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
$ ( ".HomeWorkCon form" ) . submit ( ) ;
}
$ ( '#test-program-btn' ) . show ( ) ;
$ ( '#test-program-btn' ) . show ( ) ;
return ;
return ;
}
}
@ -100,9 +92,11 @@ $(function(){
}
}
) . fail ( function ( xhr , status ) {
) . fail ( function ( xhr , status ) {
if ( status == 'timeout' ) {
if ( status == 'timeout' ) {
alert ( "您的答案超时了, 请检查代码是否存在死循环的错误." ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>您的答案超时了, 请检查代码是否存在死循环的错误!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
} else {
} else {
alert ( "对不起,服务器繁忙请稍后再试!" ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>对不起,服务器繁忙请稍后再试!</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>" ;
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
}
}
$ ( '#test-program-btn' ) . show ( ) ;
$ ( '#test-program-btn' ) . show ( ) ;
return ;
return ;
@ -120,20 +114,21 @@ $(function(){
return ;
return ;
}
}
if ( $ ( '.ProResult .ProResultTop' ) . length <= 0 ) {
if ( $ ( '.ProResult .ProResultTop' ) . length <= 0 ) {
var r = confirm ( "测试后才能提交,是否立刻测试?" ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>测试后才能提交,是否立刻测试?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' id='code-test-button' class='Blue-btn fl'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>" ;
if ( r ) {
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
$ ( "#code-test-button" ) . on ( 'click' , function ( ) {
test _program ( ) ;
test _program ( ) ;
}
hideModal ( ) ;
} ) ;
return ;
return ;
}
}
if ( ! tested ) {
if ( ! tested ) {
test _program ( function ( data ) {
test _program ( function ( data ) {
if ( data . status != 0 ) {
if ( data . status != 0 ) {
var r= confirm ( "测试不通过,是否强制提交?" ) ;
var htmlvalue = "</br><div style='width:550px;text-align:center'>测试不通过,是否强制提交?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='submit_code()'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div><script>function submit_code(){$('.HomeWorkCon form').submit();hideModal();}</script>" ;
if ( ! r ) {
pop _up _box ( htmlvalue , 580 , 30 , 50 ) ;
return ;
return ;
}
} ;
} ;
$ ( ".HomeWorkCon form" ) . submit ( ) ;
$ ( ".HomeWorkCon form" ) . submit ( ) ;
} ) ;
} ) ;