袁可 编程测试
This commit is contained in:
parent
800aaf8853
commit
26121d895f
|
@ -1,6 +1,6 @@
|
||||||
#学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品
|
#学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品
|
||||||
class StudentWork < ActiveRecord::Base
|
class StudentWork < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time
|
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty
|
||||||
|
|
||||||
belongs_to :homework_common
|
belongs_to :homework_common
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
@ -37,7 +37,7 @@ class StudentWork < ActiveRecord::Base
|
||||||
unless last_test
|
unless last_test
|
||||||
self.system_score = 0
|
self.system_score = 0
|
||||||
else
|
else
|
||||||
self.system_score = last_test.test_score
|
self.system_score = last_test.test_score self.homework_common.homework_tests.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_final_score self.homework_common,self
|
set_final_score self.homework_common,self
|
||||||
|
|
|
@ -32,13 +32,14 @@ class StudentWorkTest < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_score
|
#必须和测试集个数一样才能得100分
|
||||||
if self.status.to_i == 0
|
def test_score(testcount)
|
||||||
|
if self.status.to_i == 0 && testcount == self.results.count
|
||||||
100
|
100
|
||||||
elsif self.results.empty?
|
elsif self.results.empty?
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
get_success_count * 100 / self.results.count
|
get_success_count * 100 / testcount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ $(function(){
|
||||||
|
|
||||||
var test_program = function(cb){
|
var test_program = function(cb){
|
||||||
$('#test-program-btn').hide();
|
$('#test-program-btn').hide();
|
||||||
|
$('#commit-program-work-btn').hide();
|
||||||
var homework_id = $('#test-program-btn').attr('data-homework-id');
|
var homework_id = $('#test-program-btn').attr('data-homework-id');
|
||||||
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
|
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
|
||||||
var src = $('#program-src').val();
|
var src = $('#program-src').val();
|
||||||
|
@ -34,6 +35,7 @@ $(function(){
|
||||||
|
|
||||||
if(!valid_form()){
|
if(!valid_form()){
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
|
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
|
||||||
|
@ -48,16 +50,18 @@ $(function(){
|
||||||
//弹框
|
//弹框
|
||||||
var root_path = getRootPath();
|
var root_path = getRootPath();
|
||||||
var forums_1_path = root_path + "/forums/1"
|
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>";
|
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);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
|
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (data.status==-3){
|
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>";
|
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);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tSeq = data.tseq;
|
var tSeq = data.tseq;
|
||||||
|
@ -74,17 +78,19 @@ $(function(){
|
||||||
$('.ProResult').prepend(html);
|
$('.ProResult').prepend(html);
|
||||||
|
|
||||||
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);return;}
|
||||||
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>";
|
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(){$('#commit-program-work-btn').hide();$('#test-program-btn').hide();$('.HomeWorkCon form').submit();hideModal();}</script>";
|
||||||
pop_up_box(htmlvalue,580,30,50);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//2 超时 -2 编译错误 测试结束
|
//2 超时 -2 编译错误 测试结束
|
||||||
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
|
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
|
||||||
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;}
|
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show();$('#commit-program-work-btn').show(); return;}
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +101,11 @@ $(function(){
|
||||||
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>";
|
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);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
} else {
|
} else {
|
||||||
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>";
|
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);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
}
|
}
|
||||||
$('#test-program-btn').show();
|
$('#test-program-btn').show();
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -113,6 +120,7 @@ $(function(){
|
||||||
if(!valid_form()){
|
if(!valid_form()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$('#commit-program-work-btn').hide();
|
||||||
if($('.ProResult .ProResultTop').length<=0){
|
if($('.ProResult .ProResultTop').length<=0){
|
||||||
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>";
|
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>";
|
||||||
pop_up_box(htmlvalue,580,30,50);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
|
@ -125,16 +133,20 @@ $(function(){
|
||||||
if (!tested) {
|
if (!tested) {
|
||||||
test_program(function(data){
|
test_program(function(data){
|
||||||
if (data.status!=0) {
|
if (data.status!=0) {
|
||||||
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>";
|
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(){$('#commit-program-work-btn').hide();$('.HomeWorkCon form').submit();hideModal();}</script>";
|
||||||
pop_up_box(htmlvalue,580,30,50);
|
pop_up_box(htmlvalue,580,30,50);
|
||||||
|
$('#commit-program-work-btn').show();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
$('#commit-program-work-btn').hide();
|
||||||
|
$('#test-program-btn').hide();
|
||||||
$(".HomeWorkCon form").submit();
|
$(".HomeWorkCon form").submit();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$('#commit-program-work-btn').hide();
|
||||||
|
$('#test-program-btn').hide();
|
||||||
$(".HomeWorkCon form").submit();
|
$(".HomeWorkCon form").submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -505,7 +517,7 @@ int main()\n\
|
||||||
}\n\
|
}\n\
|
||||||
';
|
';
|
||||||
} else if(language==2){
|
} else if(language==2){
|
||||||
src = '\
|
src = '\
|
||||||
//注意\n\
|
//注意\n\
|
||||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||||
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||||
|
@ -526,7 +538,7 @@ int main()\n\
|
||||||
}\n\
|
}\n\
|
||||||
';
|
';
|
||||||
} else if(language==3){
|
} else if(language==3){
|
||||||
src = '\
|
src = '\
|
||||||
#-*-coding:utf-8-*-\n\
|
#-*-coding:utf-8-*-\n\
|
||||||
#注意\n\
|
#注意\n\
|
||||||
#1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
#1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||||
|
|
Loading…
Reference in New Issue