Merge branch 'develop' into yuanke

yuanke_1
yuanke 10 years ago
commit 879a941b01

@ -55,12 +55,11 @@ class StudentWorkController < ApplicationController
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} #保存每测试一次返回的结果
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1,testid:1} #保存每测试一次返回的结果
student_work = find_or_save_student_work(is_test)
@ -81,7 +80,7 @@ class StudentWorkController < ApplicationController
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:status] = -1
resultObj[:results] = result["results"][0] #本次测试结果
resultObj[:results] = result["results"].first #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
if result["status"].to_i == -2 #编译错误
@ -94,24 +93,6 @@ class StudentWorkController < ApplicationController
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]
@ -121,20 +102,31 @@ class StudentWorkController < ApplicationController
student_work.late_penalty = 0
end
#每次都要把数据存到数据库中
status = resultObj[:status]
if index == 1
student_work_test = student_work.student_work_tests.build(status: resultObj[:status],
results: [resultObj[:results]],src: params[:src])
student_work_test.save!
resultObj[:testid] = student_work_test.id
else
student_work_test = StudentWorkTest.find(params[:testid])
results = student_work_test.results
results << resultObj[:results]
student_work_test.results = results
student_work_test.status = (result["status"] != 0 ? result["status"] : student_work_test.status)
student_work_test.save!
status = student_work_test.status
resultObj[:testid] = student_work_test.id
end
#超时或编译错误则直接返回了并存入数据库
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
if $test_status[work_id] == 0
if status == 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
#渲染返回结果

@ -44,7 +44,7 @@ class Principal < ActiveRecord::Base
else
pattern = "%#{q}%".gsub("/","//").gsub("_","/_")
# sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ")
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p) escape '/'"
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) escape '/' or LOWER(login) LIKE LOWER(:p) escape '/' or LOWER(mail) LIKE LOWER(:p) escape '/'"
params = {:p => pattern}
if q =~ /^(.+)\s+(.+)$/
a, b = "#{$1}%", "#{$2}%"

@ -7,8 +7,8 @@
<div class="fl">
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p>
<p class="f12">
<% if course_file_num > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to course_file_num, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% if visable_attachemnts_incourse(e_course).count > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% end %>
<% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>

@ -1,6 +1,6 @@
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% teacher_num = 0 %>
<% student_num = 0 %>
<% teacher_num = TeacherAndAssistantCount(@course) %>
<% student_num = studentCount(@course) %>
<div class="pr_info_logo fl mr10 mb5">
<% if is_excellent_course(@course) %>
<img src="/images/course/boutique.png" width="50" height="auto" alt="精品" class="boutiqueP" />

@ -169,7 +169,7 @@
<div class="cl"></div>
</div><!--项目标签 end-->
<!--课程推荐-->
<%= render :partial => 'courses/recommendation', :locals => {:course => @course, :course_file_num => course_file_num} %>
<%= render :partial => 'courses/recommendation', :locals => {:course => @course} %>
<div class="fontGrey5 mt10 ml10 mb10">访问计数 <%= @course.visits.to_i %></div>
</div><!--LSide end-->

@ -12,10 +12,12 @@
if($("#document_title").val().trim() == "")
{
$("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
return false;
}
else
{
$("#doc_title_hint").hide();
return true;
}
}
</script>

@ -38,7 +38,7 @@
<div class="resources" nhname="new_topic_form" >
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
<div>
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></input>
<input class="postDetailInput fl mr15" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></input>
</div>
<div id="doc_title_hint">
</div>

@ -10,7 +10,7 @@
TO&nbsp;&nbsp;<%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
|
<span style="color:#269ac9;"><%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %></span>
<% if @organization.home_id == document.id %>
<% if document.organization.home_id == document.id %>
<span class="red_homework_btn_cir ml5">已设为首页</span>
<% end %>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -57,10 +57,12 @@ $(function(){
);
*/
//先测试一次并返回测试集个数及结果再判断是否需要继续进行测试
var test_post = function(i){
var test_post = function(i, testid){
$.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},
{homework: homework_id, student_work_id: student_work_id,
src: src, title: title, is_test: is_test,tIndex:i,
testid: testid},
function(data,status){
var tSeq = data.tseq;
var tCount = data.tcount;
@ -90,7 +92,7 @@ $(function(){
return;
}
test_post(i+1);
test_post(i+1, data.testid);
}
).fail(function(xhr, status){
if(status == 'timeout'){
@ -100,9 +102,10 @@ $(function(){
}
return;
});
};
test_post(1);
test_post(1, 0);
};
$('#test-program-btn').on('click', test_program);

Loading…
Cancel
Save