代码评测超时优化
This commit is contained in:
parent
a10830c90f
commit
c6361406b5
|
@ -4,14 +4,14 @@ 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]
|
||||
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
|
||||
before_filter :is_logged, :only => [:index]
|
||||
|
||||
###
|
||||
###
|
||||
def program_test
|
||||
is_test = params[:is_test] == 'true'
|
||||
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
|
||||
|
@ -48,13 +48,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|
|
||||
|
@ -986,7 +1075,6 @@ class StudentWorkController < ApplicationController
|
|||
student_work
|
||||
end
|
||||
|
||||
|
||||
def test_realtime(student_work, src)
|
||||
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
|
||||
|
||||
|
@ -1010,6 +1098,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
|
||||
|
|
|
@ -53,27 +53,28 @@
|
|||
<% 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 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
<span class="w150 c_red">超时!</span>
|
||||
<span class="w60 c_red">超时!</span>
|
||||
<% else %>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<span class="w60 c_red">测试错误!</span>
|
||||
<% end %>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></span>
|
||||
<span class="w60">您的输出:</span>
|
||||
<span class="width150"><pre><%=x["result"]%></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="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></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>
|
||||
|
|
|
@ -11,46 +11,48 @@
|
|||
});
|
||||
</script>
|
||||
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||
|
||||
<script id="t:result-list" type="text/html">
|
||||
<div class="ProResultTop">
|
||||
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<! 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 " >
|
||||
<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){ !>
|
||||
<! if(results[i]["status"]==2){!>
|
||||
<span class="w150 c_red">超时!</span>
|
||||
<!}else{!>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<!}!>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><!=results[i]["time_used"]!>微秒</pre></span>
|
||||
<span class="w60">您的输出:</span>
|
||||
<span class="W180"><pre><!=results[i]["result"]!></pre></span>
|
||||
<span class="w60">正确输出:</span>
|
||||
<span class="W180"><pre><!=results[i]["output"]!></pre></span>
|
||||
<div class="cl"></div>
|
||||
<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="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
|
||||
<span class="w60">正确输出:</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="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><!=results[i]["time_used"]!>微秒</pre></span>
|
||||
<span class="w60 c_green">测试正确!</span>
|
||||
<!-- <span class="w50"> 耗时:</span> -->
|
||||
<!-- <span class="w80"><pre><!=results["time_used"]!>微秒</pre></span> -->
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<!}!>
|
||||
<!}!>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
<! } !>
|
||||
|
||||
</script>
|
||||
<!-- 模板1结束 -->
|
||||
|
||||
|
@ -131,26 +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 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
<span class="w150 c_red">超时!</span>
|
||||
<span class="w60 c_red">超时!</span>
|
||||
<% else %>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<span class="w60 c_red">测试错误!</span>
|
||||
<% end %>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></span>
|
||||
<span class="w60">您的输出:</span>
|
||||
<span class="W180"><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="W180"><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="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></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 %>
|
||||
|
|
|
@ -2,44 +2,46 @@
|
|||
|
||||
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||
<script id="t:result-list" type="text/html">
|
||||
<div class="ProResultTop">
|
||||
<p class="c_blue fl">第<!=index!>次测试</p><span class="fr c_grey"><!= time !></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<! 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 " >
|
||||
<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){ !>
|
||||
<! if(results[i]["status"]==2){ !>
|
||||
<span class="w150 c_red">超时!</span>
|
||||
<!}else{!>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<!}!>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><!=results[i]["time_used"]!>微秒</pre></span>
|
||||
<span class="w60">您的输出:</span>
|
||||
<span class="W180"><pre><!=results[i]["result"]!></pre></span>
|
||||
<span class="w60">正确输出:</span>
|
||||
<span class="W180"><pre><!=results[i]["output"]!></pre></span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<!}else{!>
|
||||
<span class="w150 c_green">测试正确!</span>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><!=results[i]["time_used"]!>微秒</pre></span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<!}!>
|
||||
<!}!>
|
||||
</ul>
|
||||
</div>
|
||||
<! } !>
|
||||
<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="w180"><pre style="white-space: pre-wrap; margin-right: 15px;"><!=results["result"]!> </pre></span>
|
||||
<span class="w60">正确输出:</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="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结束 -->
|
||||
|
||||
|
@ -98,26 +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 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
<span class="w150 c_red">超时!</span>
|
||||
<span class="w60 c_red">超时!</span>
|
||||
<% else %>
|
||||
<span class="w150 c_red">测试错误!</span>
|
||||
<span class="w60 c_red">测试错误!</span>
|
||||
<% end %>
|
||||
<span class="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></span>
|
||||
<span class="w60">您的输出:</span>
|
||||
<span class="W180"><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="W180"><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="w50"> 耗时:</span>
|
||||
<span class="w80"><pre><%=x["time_used"]%>微秒</pre></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 %>
|
||||
|
|
|
@ -272,7 +272,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
|
||||
|
|
17
db/schema.rb
17
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160225031230) do
|
||||
ActiveRecord::Schema.define(:version => 20160311072819) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -432,9 +432,11 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
t.integer "resource_num"
|
||||
t.integer "journal_num"
|
||||
t.integer "journal_reply_num"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "total_score"
|
||||
t.integer "homework_journal_num", :default => 0
|
||||
t.integer "news_num", :default => 0
|
||||
end
|
||||
|
||||
create_table "course_groups", :force => true do |t|
|
||||
|
@ -506,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
t.integer "is_excellent", :default => 0
|
||||
t.integer "excellent_option", :default => 0
|
||||
t.integer "is_copy", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
create_table "custom_fields", :force => true do |t|
|
||||
|
@ -1282,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "allow_guest_download", :default => true
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
create_table "phone_app_versions", :force => true do |t|
|
||||
|
@ -1441,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
t.integer "acts_count", :default => 0
|
||||
t.integer "journals_count", :default => 0
|
||||
t.integer "boards_reply_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
@ -1900,6 +1905,7 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
t.string "mail_notification", :default => "", :null => false
|
||||
t.string "salt", :limit => 64
|
||||
t.integer "gid"
|
||||
t.integer "visits", :default => 0
|
||||
end
|
||||
|
||||
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
|
||||
|
@ -2013,11 +2019,6 @@ ActiveRecord::Schema.define(:version => 20160225031230) do
|
|||
|
||||
add_index "wikis", ["project_id"], :name => "wikis_project_id"
|
||||
|
||||
create_table "wlcs", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "workflows", :force => true do |t|
|
||||
t.integer "tracker_id", :default => 0, :null => false
|
||||
t.integer "old_status_id", :default => 0, :null => false
|
||||
|
|
|
@ -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});
|
||||
|
@ -1173,5 +1174,4 @@ function getRootPath(){
|
|||
// var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
|
||||
var projectName="";
|
||||
return(localhostPaht+projectName);
|
||||
}
|
||||
|
||||
}
|
|
@ -31,9 +31,9 @@ $(function(){
|
|||
if(!valid_form()){
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
$.post(
|
||||
'/student_work/program_test',
|
||||
'/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;
|
||||
|
@ -44,7 +44,6 @@ $(function(){
|
|||
|
||||
if (typeof cb == 'function') {cb(data); return;}
|
||||
|
||||
|
||||
var html=bt('t:result-list',data);
|
||||
$('.ProResult').prepend(html);
|
||||
|
||||
|
@ -56,6 +55,47 @@ $(function(){
|
|||
}
|
||||
}
|
||||
);
|
||||
*/
|
||||
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
|
||||
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);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
test_post(1);
|
||||
};
|
||||
|
||||
$('#test-program-btn').on('click', test_program);
|
||||
|
@ -373,6 +413,10 @@ $(function(){
|
|||
var src = '';
|
||||
if(language==4){
|
||||
src = '\
|
||||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时则接下来的测试集都不会测试了\n\
|
||||
//2:该程序每次运行使用的内存不能超过3200字节,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果不能超过3200个字符(最多显示100个字符),否则会返回错误\n\
|
||||
import java.io.*;\n\
|
||||
import java.util.*;\n\
|
||||
\n\
|
||||
|
@ -392,8 +436,12 @@ class Main\n\
|
|||
';
|
||||
}
|
||||
else if(language==1){
|
||||
src = '#include <stdio.h>\n\
|
||||
\n\
|
||||
src = '\
|
||||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时则接下来的测试集都不会测试了\n\
|
||||
//2:该程序每次运行使用的内存不能超过3200字节,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果不能超过3200个字符(最多显示100个字符),否则会返回错误\n\
|
||||
#include <stdio.h>\n\
|
||||
int main()\n\
|
||||
{\n\
|
||||
//获取参数方式 scanf\n\
|
||||
|
@ -409,6 +457,10 @@ int main()\n\
|
|||
';
|
||||
} else if(language==2){
|
||||
src = '\
|
||||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时则接下来的测试集都不会测试了\n\
|
||||
//2:该程序每次运行使用的内存不能超过3200字节,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果不能超过3200个字符(最多显示100个字符),否则会返回错误\n\
|
||||
#include <iostream>\n\
|
||||
using namespace std;\n\
|
||||
\n\
|
||||
|
@ -426,6 +478,10 @@ int main()\n\
|
|||
';
|
||||
} else if(language==3){
|
||||
src = '\
|
||||
#注意\n\
|
||||
#1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时则接下来的测试集都不会测试了\n\
|
||||
#2:该程序每次运行使用的内存不能超过3200字节,否则会返回错误\n\
|
||||
#3:该程序每次运行输出的结果不能超过3200个字符(最多显示100个字符),否则会返回错误\n\
|
||||
import sys \n\
|
||||
\n\
|
||||
#获取参数方式,使用raw_input\n\
|
||||
|
|
|
@ -442,6 +442,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;}
|
||||
|
|
|
@ -146,6 +146,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;}
|
||||
|
|
Loading…
Reference in New Issue