袁可 编程测试
This commit is contained in:
parent
800aaf8853
commit
26121d895f
|
@ -1,6 +1,6 @@
|
|||
#学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品
|
||||
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 :user
|
||||
|
@ -30,15 +30,15 @@ class StudentWork < ActiveRecord::Base
|
|||
student_work_tests.order('id desc').first
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
def set_program_score
|
||||
if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
|
||||
#根据最后一次测试计算得分
|
||||
unless last_test
|
||||
self.system_score = 0
|
||||
else
|
||||
self.system_score = last_test.test_score
|
||||
end
|
||||
#根据最后一次测试计算得分
|
||||
unless last_test
|
||||
self.system_score = 0
|
||||
else
|
||||
self.system_score = last_test.test_score self.homework_common.homework_tests.size
|
||||
end
|
||||
end
|
||||
set_final_score self.homework_common,self
|
||||
end
|
||||
|
@ -133,7 +133,7 @@ class StudentWork < ActiveRecord::Base
|
|||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
|
|
|
@ -32,13 +32,14 @@ class StudentWorkTest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def test_score
|
||||
if self.status.to_i == 0
|
||||
#必须和测试集个数一样才能得100分
|
||||
def test_score(testcount)
|
||||
if self.status.to_i == 0 && testcount == self.results.count
|
||||
100
|
||||
elsif self.results.empty?
|
||||
0
|
||||
else
|
||||
get_success_count * 100 / self.results.count
|
||||
else
|
||||
get_success_count * 100 / testcount
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
$(function(){
|
||||
//提交作业
|
||||
|
||||
|
||||
var bt=baidu.template;
|
||||
bt.LEFT_DELIMITER='<!';
|
||||
bt.RIGHT_DELIMITER='!>';
|
||||
|
||||
|
||||
var tested = false;
|
||||
var valid_form = function() {
|
||||
var src = $('#program-src').val();
|
||||
|
@ -26,6 +26,7 @@ $(function(){
|
|||
|
||||
var test_program = function(cb){
|
||||
$('#test-program-btn').hide();
|
||||
$('#commit-program-work-btn').hide();
|
||||
var homework_id = $('#test-program-btn').attr('data-homework-id');
|
||||
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
|
||||
var src = $('#program-src').val();
|
||||
|
@ -34,6 +35,7 @@ $(function(){
|
|||
|
||||
if(!valid_form()){
|
||||
$('#test-program-btn').show();
|
||||
$('#commit-program-work-btn').show();
|
||||
return;
|
||||
}
|
||||
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
|
||||
|
@ -42,22 +44,24 @@ $(function(){
|
|||
'/student_work/program_test_ex',
|
||||
{homework: homework_id, student_work_id: student_work_id,
|
||||
src: src, title: title, is_test: is_test,tIndex:i,
|
||||
testid: testid},
|
||||
testid: testid},
|
||||
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>";
|
||||
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();
|
||||
$('#commit-program-work-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>";
|
||||
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();
|
||||
$('#commit-program-work-btn').show();
|
||||
return;
|
||||
}
|
||||
var tSeq = data.tseq;
|
||||
|
@ -74,17 +78,19 @@ $(function(){
|
|||
$('.ProResult').prepend(html);
|
||||
|
||||
if (data.status==0 && is_test != 'true') {
|
||||
if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); 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>";
|
||||
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(){$('#commit-program-work-btn').hide();$('#test-program-btn').hide();$('.HomeWorkCon form').submit();hideModal();}</script>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
||||
$('#test-program-btn').show();
|
||||
$('#commit-program-work-btn').show();
|
||||
return;
|
||||
}
|
||||
|
||||
//2 超时 -2 编译错误 测试结束
|
||||
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();
|
||||
$('#commit-program-work-btn').show();
|
||||
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>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
||||
} 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);
|
||||
}
|
||||
$('#test-program-btn').show();
|
||||
$('#commit-program-work-btn').show();
|
||||
return;
|
||||
});
|
||||
};
|
||||
|
@ -113,6 +120,7 @@ $(function(){
|
|||
if(!valid_form()){
|
||||
return;
|
||||
}
|
||||
$('#commit-program-work-btn').hide();
|
||||
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>";
|
||||
pop_up_box(htmlvalue,580,30,50);
|
||||
|
@ -125,16 +133,20 @@ $(function(){
|
|||
if (!tested) {
|
||||
test_program(function(data){
|
||||
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);
|
||||
$('#commit-program-work-btn').show();
|
||||
return;
|
||||
|
||||
};
|
||||
$(".HomeWorkCon form").submit();
|
||||
$('#commit-program-work-btn').hide();
|
||||
$('#test-program-btn').hide();
|
||||
$(".HomeWorkCon form").submit();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$('#commit-program-work-btn').hide();
|
||||
$('#test-program-btn').hide();
|
||||
$(".HomeWorkCon form").submit();
|
||||
});
|
||||
|
||||
|
@ -147,7 +159,7 @@ $(function(){
|
|||
$('#program-src').focus(function(){
|
||||
$(this).css('height', '100px');
|
||||
});
|
||||
|
||||
|
||||
var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true};
|
||||
|
||||
$('input.date-input').datepicker(datepickerOptions);
|
||||
|
@ -207,10 +219,10 @@ $(function(){
|
|||
|
||||
|
||||
$("#BluePopupBox").dialog({
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
dialogClass: 'BluePopupBox',
|
||||
minWidth: 771
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
dialogClass: 'BluePopupBox',
|
||||
minWidth: 771
|
||||
});
|
||||
$('#BluePopupBox').parent().resizable("disable");
|
||||
$('#BluePopupBox').parent().removeClass("ui-state-disabled");
|
||||
|
@ -249,7 +261,7 @@ $(function(){
|
|||
|
||||
var saveProgramAnswers = function() {
|
||||
var test_numbers = 0;
|
||||
var valid = true;
|
||||
var valid = true;
|
||||
var input = null;
|
||||
var output = null;
|
||||
var input_groups = [];
|
||||
|
@ -300,7 +312,7 @@ $(function(){
|
|||
$("#BluePopupBox a.BlueCirBtn").live('click', function(){
|
||||
if(saveProgramAnswers()){
|
||||
if($( "#BluePopupBox" ).dialog( "isOpen" )){
|
||||
$("#BluePopupBox").dialog( "close" );
|
||||
$("#BluePopupBox").dialog( "close" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -449,7 +461,7 @@ $(function(){
|
|||
var program_name = "text/x-csrc";
|
||||
var language = $('#data-language').attr('data-language');
|
||||
if (language == 1) {
|
||||
program_name = 'text/x-csrc';
|
||||
program_name = 'text/x-csrc';
|
||||
} else if(language==2){
|
||||
program_name = 'text/x-c++src';
|
||||
}else if(language==3){
|
||||
|
@ -483,8 +495,8 @@ class Main\n\
|
|||
}\n\
|
||||
}\n\
|
||||
';
|
||||
}
|
||||
else if(language==1){
|
||||
}
|
||||
else if(language==1){
|
||||
src = '\
|
||||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
|
@ -504,8 +516,8 @@ int main()\n\
|
|||
return 0;\n\
|
||||
}\n\
|
||||
';
|
||||
} else if(language==2){
|
||||
src = '\
|
||||
} else if(language==2){
|
||||
src = '\
|
||||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||
|
@ -525,8 +537,8 @@ int main()\n\
|
|||
return 0;\n\
|
||||
}\n\
|
||||
';
|
||||
} else if(language==3){
|
||||
src = '\
|
||||
} else if(language==3){
|
||||
src = '\
|
||||
#-*-coding:utf-8-*-\n\
|
||||
#注意\n\
|
||||
#1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
|
@ -541,15 +553,15 @@ import sys \n\
|
|||
#结果输出使用 print \n\
|
||||
#print (str(int(a)+int(b)))\n\
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
$('#program-src').val(src);
|
||||
$('#program-src').val(src);
|
||||
};
|
||||
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("program-src"), {
|
||||
mode: {name: program_name,
|
||||
version: 2,
|
||||
singleLineStringErrors: false},
|
||||
version: 2,
|
||||
singleLineStringErrors: false},
|
||||
lineNumbers: true,
|
||||
indentUnit: 2,
|
||||
matchBrackets: true
|
||||
|
@ -560,7 +572,7 @@ import sys \n\
|
|||
$('#program-src').val(cMirror.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
Loading…
Reference in New Issue