Merge branch 'yuanke' into develop

This commit is contained in:
yuanke 2016-03-25 16:38:56 +08:00
commit 09fc2589a9
14 changed files with 1557 additions and 1328 deletions

View File

@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController
include ApplicationHelper
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
@ -49,13 +49,102 @@ class StudentWorkController < ApplicationController
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
end
end
end
render :json => resultObj
end
$test_result = {}
$test_status = {}
#根据传入的tIndex确定是第几次测试
def program_test_ex
is_test = params[:is_test] == 'true'
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1} #保存每测试一次返回的结果
student_work = find_or_save_student_work(is_test)
resultObj[:tcount] = @homework.homework_tests.size
unless student_work
resultObj[:status] = 100
else
if @homework.homework_type == 2 && @homework.homework_detail_programing
#找到第index个测试的输入输出
index = params[:tIndex].to_i
resultObj[:tseq] = index
test = @homework.homework_tests[index - 1]
#请求测试
result = test_realtime_ex(test, params[:src])
logger.debug result
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:status] = -1
resultObj[:results] = result["results"][0] #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
if result["status"].to_i == -2 #编译错误
resultObj[:status] = -2
elsif result["results"][0]["status"].to_i == 2
resultObj[:status] = 2
end
unless student_work.save
resultObj[:status] = 200
else
#索引
work_id = student_work.id
#测试第一个时初始化下全局变量
if index == 1
$test_result[work_id] = [] #保存本次测试的结果 输入输出
$test_status[work_id] = 0 #保存本次测试的结果 正确还是错误
end
if result["status"].to_i == -2
$test_result[work_id] = [result["error_msg"]]
$test_status[work_id] = -2
else
#存下每次的结果 只有每次都为0才全部正确
$test_status[work_id] = result["status"] != 0 ? result["status"]:$test_status[work_id]
$test_result[work_id][index - 1] = resultObj[:results]
end
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
end
#超时或编译错误则直接返回了并存入数据库
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
if $test_status[work_id] == 0
resultObj[:status] = 0
end
student_work_test = student_work.student_work_tests.build(status: $test_status[work_id],
results: $test_result[work_id],src: params[:src])
student_work.save
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
$test_result[work_id] = nil
$test_status[work_id] = nil
end
#渲染返回结果
render :json => resultObj
end
end
end
end
def index
# 作业消息状态更新
@homework.course_messages.each do |homework_message|
@ -996,7 +1085,6 @@ class StudentWorkController < ApplicationController
student_work
end
def test_realtime(student_work, src)
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
@ -1020,6 +1108,28 @@ class StudentWorkController < ApplicationController
JSON.parse(res.body)
end
def test_realtime_ex(test, src)
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
factor = []
factor << {input: test.input, output: test.output}
solutions = {
src:src,
language:@homework.homework_detail_programing.language,
factor: factor
}
uri = URI(url)
body = solutions.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
JSON.parse(res.body)
end
#成绩计算
def set_final_score homework,student_work
if homework && homework.homework_detail_manual

View File

@ -53,18 +53,32 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<% test.results.reverse.each_with_index do |x, i| %>
<li >
<span class="w60 T_C">测试<%=i+1%></span>
<span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="width150"><pre><%=x["result"].force_encoding("UTF-8")%></pre></span>
<span class="width120"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="width150"><pre><%=x["output"]%></pre></span>
<span class="width120"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["output"]%></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50">耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
<% end %>
</li>

View File

@ -11,43 +11,53 @@
});
</script>
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<! if((tseq == tcount) ||(status == 2)||(status == -2)){ !>
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<!}!>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<div class="ProResultCon "><pre style="white-space: pre-wrap;"><!= error_msg !></pre></div>
<!}else{!>
<div class="ProResultTable ">
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<li ><span class="w60 T_C">测试<!=tseq!></span>
<! if(results["status"]!=0){ !>
<! if(results["status"]==2){!>
<span class="w60 c_red">超时!</span>
<!}else{!>
<span class="w60 c_red">测试错误!</span>
<!}!>
<span class="w60">您的输出:</span>
<span class="W200"><pre><!=results[i]["result"]!></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><!=results[i]["output"]!></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["output"]!></pre></span>
<! if(results["status"]==2){!>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><!=results["time_used"]!>毫秒</pre></span>
<!}!>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><!=results["time_used"]!>微秒</pre></span> -->
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
<div class="ProgramHomework ml10">
<div class="homepageRightBanner mb10">
<div class="NewsBannerName"><%= @is_test ? '模拟答题' : '提交作品' %></div>
</div>
@ -123,18 +133,28 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% test.results.reverse.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="W200"><pre><%=x["result"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><%= x["output"] %></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%= x["output"] %></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
</li>
<% end %>

View File

@ -2,36 +2,46 @@
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<script id="t:result-list" type="text/html">
<! if((tseq == tcount) ||(status == 2)||(status == -2)){ !>
<div class="ProResultTop">
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
<div class="cl"></div>
</div>
<!}!>
<! if(status == -2){!>
<div class="ProResultCon "><!= error_msg !></div>
<div class="ProResultCon "><pre style="white-space: pre-wrap;"><!= error_msg !></pre></div>
<!}else{!>
<div class="ProResultTable ">
<ul class="ProResultUl " >
<! for(var i =0; i <results.length; ++i){ !>
<li ><span class="w60 T_C">测试<!=i+1!></span>
<! if(results[i]["status"]!=0){ !>
<span class="w150 c_red">测试错误!</span>
<li ><span class="w60 T_C">测试<!=tseq!></span>
<! if(results["status"]!=0){ !>
<! if(results["status"]==2){!>
<span class="w60 c_red">超时!</span>
<!}else{!>
<span class="w60 c_red">测试错误!</span>
<!}!>
<span class="w60">您的输出:</span>
<span class="W200"><pre><!=results[i]["result"]!></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><!=results[i]["output"]!></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["output"]!></pre></span>
<! if(results["status"]==2){!>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><!=results["time_used"]!>毫秒</pre></span>
<!}!>
<div class="cl"></div>
</li>
<!}else{!>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!-- <span class="w50"> 耗时:</span> -->
<!-- <span class="w80"><pre><!=results["time_used"]!>微秒</pre></span> -->
<div class="cl"></div>
</li>
<!}!>
<!}!>
</ul>
</div>
<! } !>
</script>
<!-- 模板1结束 -->
@ -90,18 +100,28 @@
<% else %>
<div class="ProResultTable " >
<ul class="ProResultUl " >
<% test.results.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=i+1%></span>
<% test.results.reverse.each_with_index do |x, i| %>
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
<% if x["status"].to_i != 0 %>
<span class="w150 c_red">测试错误!</span>
<% if x["status"].to_i == 2 %>
<span class="w60 c_red">超时!</span>
<% else %>
<span class="w60 c_red">测试错误!</span>
<% end %>
<span class="w60">您的输出:</span>
<span class="W200"><pre><%=x["result"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["result"]%> </pre></span>
<span class="w60">正确输出:</span>
<span class="W200"><pre><%=x["output"]%></pre></span>
<span class="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><%=x["output"]%></pre></span>
<% if x["status"].to_i == 2 %>
<span class="w50"> 耗时:</span>
<span class="w80"><pre><%=x["time_used"]%>毫秒</pre></span>
<% end %>
<div class="cl"></div>
</li>
<% else %>
<span class="w150 c_green">测试正确!</span>
<span class="w60 c_green">测试正确!</span>
<!--<span class="w50"> 耗时:</span> -->
<!--<span class="w80"><pre><%=x["time_used"]%>微秒</pre></span> -->
<div class="cl"></div>
</li>
<% end %>

View File

@ -273,7 +273,7 @@ RedmineApp::Application.routes.draw do
get 'absence_penalty_list'
get 'evaluation_list'
# post 'set_program_score'
post 'program_test'
post 'program_test_ex'
post 'set_score_rule'
end
end

View File

@ -14,7 +14,7 @@ module RailsKindeditor
output = ActiveSupport::SafeBuffer.new
output << text_area_tag(name, content, input_html)
output << javascript_tag(js_replace(id, options.merge(window_onload: 'true',
:autoHeightMode=>false,
:autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高
afterCreate: eval_str(at_id, at_type),
emotionsBasePath: 'http://' + Setting.host_name
)))
@ -29,7 +29,7 @@ module RailsKindeditor
output_buffer = ActiveSupport::SafeBuffer.new
output_buffer << build_text_area_tag(name, method, self, options, input_html)
output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true',
:autoHeightMode=>false,
:autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高
afterCreate: eval_str(at_id, at_type),
emotionsBasePath: 'http://' + Setting.host_name
)))

View File

@ -174,7 +174,7 @@ function(a,c){var d=J(c,["prop","delete"])<0?b.plugin.getSelectedCell:b.plugin.g
function(a,d){c[d]&&b.afterCreate(function(){Ka(this.edit.doc,c[d],function(){b.cmd.selection();b.clickToolbar(d)})});b.clickToolbar(d,function(){b.focus().exec(d,null)})});b.afterCreate(function(){function c(){f.range.moveToBookmark(j);f.select();X&&(a("div."+l,i).each(function(){a(this).after("<br />").remove(!0)}),a("span.Apple-style-span",i).remove(!0),a("span.Apple-tab-span",i).remove(!0),a("span[style]",i).each(function(){a(this).css("white-space")=="nowrap"&&a(this).remove(!0)}),a("meta",i).remove());
var d=i[0].innerHTML;i.remove();d!==""&&(X&&(d=d.replace(/(<br>)\1/ig,"$1")),b.pasteType===2&&(d=d.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/ig,""),/schemas-microsoft-com|worddocument|mso-\w+/i.test(d)?d=nb(d,b.filterMode?b.htmlTags:a.options.htmlTags):(d=U(d,b.filterMode?b.htmlTags:null),d=b.beforeSetHtml(d))),b.pasteType===1&&(d=d.replace(/&nbsp;/ig," "),d=d.replace(/\n\s*\n/g,"\n"),d=d.replace(/<br[^>]*>/ig,"\n"),d=d.replace(/<\/p><p[^>]*>/ig,"\n"),d=d.replace(/<[^>]+>/g,""),d=d.replace(/ {2}/g," &nbsp;"),
b.newlineTag=="p"?/\n/.test(d)&&(d=d.replace(/^/,"<p>").replace(/$/,"<br /></p>").replace(/\n/g,"<br /></p><p>")):d=d.replace(/\n/g,"<br />$&")),b.insertHtml(d,!0))}var d=b.edit.doc,f,j,i,l="__kindeditor_paste__",m=!1;a(d.body).bind("paste",function(p){if(b.pasteType===0)p.stop();else if(!m){m=!0;a("div."+l,d).remove();f=b.cmd.selection();j=f.range.createBookmark();i=a('<div class="'+l+'"></div>',d).css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",left:"-1981px",top:a(j.start).pos().y+
"px","white-space":"nowrap"});a(d.body).append(i);if(o){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(<input)((?:\s+[^>]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+
"px","white-space":"nowrap"});a(d.body).append(i);if(o||Yb){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(<input)((?:\s+[^>]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+
c;return a}));return a.replace(/(<(?:noscript|noscript\s[^>]*)>)([\s\S]*?)(<\/noscript>)/ig,function(a,b,c,d){return b+fa(c).replace(/\s+/g," ")+d}).replace(/<img[^>]*class="?ke-(flash|rm|media)"?[^>]*>/ig,function(a){var a=I(a),b=ba(a.style||""),c=pb(a["data-ke-tag"]),d=l(b.width,""),b=l(b.height,"");/px/i.test(d)&&(d=t(d));/px/i.test(b)&&(b=t(b));c.width=l(a.width,d);c.height=l(a.height,b);return Ma(c)}).replace(/<img[^>]*class="?ke-anchor"?[^>]*>/ig,function(a){a=I(a);return'<a name="'+unescape(a["data-ke-name"])+
'"></a>'}).replace(/<div\s+[^>]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return"<script"+unescape(b)+">"+unescape(c)+"<\/script>"}).replace(/<div\s+[^>]*data-ke-noscript-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return"<noscript"+unescape(b)+">"+unescape(c)+"</noscript>"}).replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/ig,function(a,b,c){a=a.replace(/(\s+(?:href|src)=")[^"]*(")/i,function(a,b,d){return b+fa(c)+d});return a=a.replace(/\s+data-ke-src="[^"]*"/i,
"")}).replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/ig,function(a,b,c){return b+c})});b.beforeSetHtml(function(a){o&&A<=8&&(a=a.replace(/<input[^>]*>|<(select|button)[^>]*>[\s\S]*?<\/\1>/ig,function(a){var b=I(a);if(ba(b.style||"").display=="none")return'<div class="ke-display-none" data-ke-input-tag="'+escape(a)+'"></div>';return a}));return a.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig,function(a){a=I(a);a.src=l(a.src,"");a.width=l(a.width,0);a.height=l(a.height,0);return qb(b.themesPath+

View File

@ -251,7 +251,7 @@ K.options = {
langType : 'zh_CN',
urlType : '',
newlineTag : 'p',
resizeType : 2,
resizeType : 1,
syncType : 'form',
pasteType : 2,
dialogAlignType : 'page',
@ -4938,7 +4938,7 @@ KEditor.prototype = {
afterSetHtml : function(fn) {
return this.handler('afterSetHtml', fn);
},
create : function() {
create : function() {K
var self = this, fullscreenMode = self.fullscreenMode;
if (self.isCreated) {
return self;
@ -5076,8 +5076,11 @@ KEditor.prototype = {
self.afterSetHtml();
},
afterCreate : function() {
self.loadPlugin('autoheight');
self.edit = edit = this;
self.cmd = edit.cmd;
//edit.iframe[0].scroll = 'no';
//edit.doc.body.style.overflowY = 'hidden';
self._docMousedownFn = function(e) {
if (self.menu) {
self.hideMenu();
@ -6015,6 +6018,7 @@ _plugin('core', function(K) {
'white-space' : 'nowrap'
});
K(doc.body).append(div);
if (_IE) {
var rng = cmd.range.get(true);
rng.moveToElementText(div[0]);

View File

@ -9,7 +9,7 @@
KindEditor.plugin('autoheight', function(K) {
var self = this;
//self.autoHeightMode = true;
if (!self.autoHeightMode) {
return;
}

View File

@ -1018,6 +1018,7 @@ function showNormalImage(id) {
$(image).attr('src',_src);
return;
}
var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element);
$(image).parent().colorbox({rel:'nofollow', close: "关闭", returnFocus: false});

View File

@ -31,19 +31,19 @@ $(function(){
if(!valid_form()){
return;
}
$.ajax({
url: '/student_work/program_test',
type: 'POST',
timeout: 60*1000,
data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
}).done(function(data){
/*
$.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);
@ -53,15 +53,58 @@ $(function(){
$(".HomeWorkCon form").submit();
}
}
}).fail(function(xhr, status){
}
);
*/
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
var test_post = function(i){
$.post(
'/student_work/program_test_ex',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test,tIndex:i},
function(data,status){
var tSeq = data.tseq;
var tCount = data.tcount;
console.log("tSeq="+tSeq);
console.log("tCount="+tCount);
tested = true;
console.log(data);
if(data.index <=0){
data.index = $('.ProResultTop').length+1;
}
var html=bt('t:result-list',data);
$('.ProResult').prepend(html);
if (data.status==0 && is_test != 'true') {
if (typeof cb == 'function') {cb(data); return;}
var r=confirm("答题正确,是否立刻提交?");
if (r) {
$(".HomeWorkCon form").submit();
}
return;
}
//2 超时 -2 编译错误 测试结束
if (data.status == 2 || data.status == -2 || tSeq >= tCount ){
if (typeof cb == 'function') {cb(data); return;}
return;
}
test_post(i+1);
}
).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.")
alert("测试失败,服务器出错.");
return;
}
});
};
test_post(1);
};
$('#test-program-btn').on('click', test_program);
@ -377,6 +420,10 @@ $(function(){
var src = '';
if(language==4){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
import java.io.*;\n\
import java.util.*;\n\
\n\
@ -396,8 +443,12 @@ class Main\n\
';
}
else if(language==1){
src = '#include <stdio.h>\n\
\n\
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
#include <stdio.h>\n\
int main()\n\
{\n\
//获取参数方式 scanf\n\
@ -413,6 +464,10 @@ int main()\n\
';
} else if(language==2){
src = '\
//注意\n\
//1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
//2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
#include <iostream>\n\
using namespace std;\n\
\n\
@ -430,6 +485,10 @@ int main()\n\
';
} else if(language==3){
src = '\
#注意\n\
#1:该程序每次运行的时间必须小于200毫秒否则会超时,程序超时将不会测试剩余的测试集\n\
#2:该程序每次运行使用的内存不能超过1M否则会返回错误\n\
#3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
import sys \n\
\n\
#获取参数方式使用raw_input\n\

View File

@ -443,6 +443,7 @@ a:hover.tijiao{ background:#0f99a9;}
.members_left ul li span{ float:left; text-align:center; color:#484747;}
.w150{ text-align:center; width:150px;min-height: 10px;}
.width150{width:150px;min-height: 10px;}
.width120{width:120px;min-height: 10px;}
.f_b{ font-weight: bold;}
.members_right label{ margin-left:15px;}
.N_search{ height:20px; border:1px solid #999;}

View File

@ -1483,8 +1483,7 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
.subject-list-from {width:145px; text-align:center;}
/*视频播放默认图标*/
.mediaIco{margin: 30px 0 30px 20px;}
.mediaIco{margin: 30px 0 30px 20px;width: 200px;}
a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;}
a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;}
a:hover.st_img { border:1px solid #1c9ec7; }

View File

@ -147,6 +147,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w90{ width:90px;}
.w100{width: 100px;}
.w125{width:125px;}
.w180{width:180px;}
.w210{ width:210px;}
.w150{ width:150px;}
.w170{width:170px;}