Merge branch 'develop' into ouyangxuhua
This commit is contained in:
commit
a69997f6c7
|
@ -55,12 +55,34 @@ class StudentWorkController < ApplicationController
|
|||
render :json => resultObj
|
||||
end
|
||||
|
||||
$test_result = {}
|
||||
$test_status = {}
|
||||
#行尾空格替换成□
|
||||
def space_replace_1(str)
|
||||
for i in 0 .. str.size
|
||||
tChar = str[i]
|
||||
if tChar != ' ' && tChar != "\n"
|
||||
sFlag = false
|
||||
eFlag = false
|
||||
elsif tChar == ' ' && sFlag == false
|
||||
tStart = i
|
||||
sFlag = true
|
||||
elsif tChar == "\n"
|
||||
tEnd = i - 1
|
||||
if sFlag == true
|
||||
for j in tStart .. tEnd
|
||||
str[j] = "□"
|
||||
end
|
||||
sFlag = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#由于负载问题 不要使用全局变量
|
||||
#根据传入的tIndex确定是第几次测试
|
||||
#之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来
|
||||
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)
|
||||
|
||||
|
@ -77,14 +99,24 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#请求测试
|
||||
result = test_realtime_ex(test, params[:src])
|
||||
logger.debug result
|
||||
|
||||
if result["status"].to_i != -2
|
||||
#result["results"].first['output'] = result["results"].first['output'].gsub(" ","□")
|
||||
#result["results"].first['result'] = result["results"].first['result'].gsub(" ","□")
|
||||
end
|
||||
|
||||
space_replace_1(result["results"].first['output'])
|
||||
space_replace_1(result["results"].first['result'])
|
||||
|
||||
logger.debug result
|
||||
|
||||
#-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 #编译错误
|
||||
resultObj[:results] = result["error_msg"]
|
||||
resultObj[:status] = -2
|
||||
elsif result["results"][0]["status"].to_i == 2
|
||||
resultObj[:status] = 2
|
||||
|
@ -93,25 +125,6 @@ class StudentWorkController < ApplicationController
|
|||
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]
|
||||
|
||||
|
@ -121,20 +134,33 @@ class StudentWorkController < ApplicationController
|
|||
student_work.late_penalty = 0
|
||||
end
|
||||
|
||||
#每次从数据库取出上次的结果加上本次的结果再存入数据库
|
||||
status = result["status"]
|
||||
if index == 1
|
||||
student_work_test = student_work.student_work_tests.build(status: status,
|
||||
results: [resultObj[:results]],src: params[:src])
|
||||
student_work_test.save!
|
||||
resultObj[:testid] = student_work_test.id
|
||||
else
|
||||
#先从数据库取出result
|
||||
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
|
||||
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
|
||||
|
||||
#渲染返回结果
|
||||
|
|
|
@ -130,7 +130,7 @@ module StudentWorkHelper
|
|||
def revise_attachment_status homework, attach
|
||||
date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d")
|
||||
status = ""
|
||||
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date))
|
||||
if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time.to_s < date))
|
||||
status = "此时其他同学作品已公开"
|
||||
else
|
||||
status = "此时其他同学作品尚未公开"
|
||||
|
|
|
@ -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,7 @@
|
|||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<% teacher_num = TeacherAndAssistantCount(@course) %>
|
||||
<% student_num = studentCount(@course) %>
|
||||
<% course_file_num = visable_attachemnts_incourse(@course).count %>
|
||||
<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" />
|
||||
|
|
|
@ -55,8 +55,7 @@
|
|||
<div id="content">
|
||||
<div id="LSide" class="fl">
|
||||
<div class="project_info" style="position: relative" id="project_info_<%=@course.id %>">
|
||||
<% course_file_num = visable_attachemnts_incourse(@course).count %>
|
||||
<%=render :partial=>'layouts/project_info', :locals => {:course_file_num => course_file_num} %>
|
||||
<%=render :partial=>'layouts/project_info' %>
|
||||
</div><!--课程信息 end-->
|
||||
<div class="info_box">
|
||||
<ul>
|
||||
|
@ -169,7 +168,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>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</script>
|
||||
|
||||
<% unless forge_acts.empty? %>
|
||||
<% forge_acts.includes(:forge_act).each do |activity| -%>
|
||||
<% forge_acts.each do |activity| -%>
|
||||
<script>
|
||||
function expand_reply(container, btnid) {
|
||||
var target = $(container);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%>
|
||||
<!-- 匿评结束阶段,显示点赞按钮 -->
|
||||
<li class="fr" id="student_work_praise_<%= work.id%>">
|
||||
<%= render :partial => 'student_work_praise' %>
|
||||
<%= render :partial => 'student_work_praise',:locals => {:work => work} %>
|
||||
</li>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
|
@ -55,8 +55,8 @@
|
|||
<ul class="ProResultUl " >
|
||||
|
||||
<% test.results.reverse.each_with_index do |x, i| %>
|
||||
<% unless x.nil? %>
|
||||
<li >
|
||||
|
||||
<span class="w60 T_C">测试<%=test.results.size-i%></span>
|
||||
<% if x["status"].to_i != 0 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
|
@ -82,6 +82,7 @@
|
|||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %>
|
||||
<!-- 匿评结束阶段,显示点赞按钮 -->
|
||||
<li class="fr" id="student_work_praise_<%= work.id%>">
|
||||
<%= render :partial => 'student_work_praise' %>
|
||||
<%= render :partial => 'student_work_praise',:locals => {:work => work} %>
|
||||
</li>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<% if is_praise_homework User.current.id,@work.id %>
|
||||
<%= link_to "赞(#{praise_homework_count @work.id})",praise_student_work_student_work_path(@work), :remote => true,:class => 'orange_btn', :style => 'font-size:12px;'%>
|
||||
<% if is_praise_homework User.current.id,work.id %>
|
||||
<%= link_to "赞(#{praise_homework_count work.id})",praise_student_work_student_work_path(work), :remote => true,:class => 'orange_btn', :style => 'font-size:12px;'%>
|
||||
<% else %>
|
||||
<%= link_to "赞(#{praise_homework_count @work.id})","javascript:void(0)",:class => 'grey_btn', :style => 'font-size:12px;'%>
|
||||
<%= link_to "赞(#{praise_homework_count work.id})","javascript:void(0)",:class => 'grey_btn', :style => 'font-size:12px;'%>
|
||||
<% end %>
|
|
@ -1 +1 @@
|
|||
$('#student_work_praise_<%= @work.id%>').html('<%= escape_javascript(render :partial => 'student_work/student_work_praise')%>');
|
||||
$('#student_work_praise_<%= @work.id%>').html('<%= escape_javascript(render :partial => 'student_work/student_work_praise', :locals => {:work => @work})%>');
|
|
@ -30,7 +30,7 @@
|
|||
<! if(results["status"]==2){!>
|
||||
<span class="w60 c_red">超时!</span>
|
||||
<!}else{!>
|
||||
<span class="w60 c_red">测试错误!</span>
|
||||
<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>
|
||||
|
@ -133,7 +133,9 @@
|
|||
<% else %>
|
||||
<div class="ProResultTable " >
|
||||
<ul class="ProResultUl " >
|
||||
<% test.results.reverse.each_with_index do |x, i| %>
|
||||
<% logger.error("################################################{test.results}") %>
|
||||
<% test.results.reverse.each_with_index do |x, i| %>
|
||||
<% unless x.nil? %>
|
||||
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
|
||||
<% if x["status"].to_i != 0 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
|
@ -159,6 +161,7 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
<div class="ProResultTable " >
|
||||
<ul class="ProResultUl " >
|
||||
<% test.results.reverse.each_with_index do |x, i| %>
|
||||
<% unless x.nil? %>
|
||||
<li ><span class="w60 T_C">测试<%=test.results.size-i%></span>
|
||||
<% if x["status"].to_i != 0 %>
|
||||
<% if x["status"].to_i == 2 %>
|
||||
|
@ -125,6 +126,7 @@
|
|||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
class UpdateOneStudentTeacherScore < ActiveRecord::Migration
|
||||
def up
|
||||
work = StudentWork.find 49774
|
||||
score = StudentWorksScore.new
|
||||
score.score = 100
|
||||
score.user_id = 7318
|
||||
score.student_work_id = work.id
|
||||
score.reviewer_role = 1
|
||||
if score.save
|
||||
work.teacher_score = score.score
|
||||
end
|
||||
work.save
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160325030423) do
|
||||
ActiveRecord::Schema.define(:version => 20160329014316) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
|
@ -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,19 +92,20 @@ $(function(){
|
|||
return;
|
||||
}
|
||||
|
||||
test_post(i+1);
|
||||
test_post(i+1, data.testid);
|
||||
}
|
||||
).fail(function(xhr, status){
|
||||
if(status == 'timeout'){
|
||||
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
|
||||
} else {
|
||||
alert("测试失败,服务器出错.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
test_post(1);
|
||||
test_post(1, 0);
|
||||
};
|
||||
|
||||
$('#test-program-btn').on('click', test_program);
|
||||
|
@ -423,7 +426,7 @@ $(function(){
|
|||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
|
||||
import java.io.*;\n\
|
||||
import java.util.*;\n\
|
||||
\n\
|
||||
|
@ -447,7 +450,7 @@ class Main\n\
|
|||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
|
||||
#include <stdio.h>\n\
|
||||
int main()\n\
|
||||
{\n\
|
||||
|
@ -467,7 +470,7 @@ src = '\
|
|||
//注意\n\
|
||||
//1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
//2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
|
||||
//3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\
|
||||
#include <iostream>\n\
|
||||
using namespace std;\n\
|
||||
\n\
|
||||
|
@ -488,7 +491,7 @@ src = '\
|
|||
#注意\n\
|
||||
#1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\
|
||||
#2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\
|
||||
#3:该程序每次运行输出的结果最多显示100个字符(多余的不显示)\n\
|
||||
#3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),空格用□表示\n\
|
||||
import sys \n\
|
||||
\n\
|
||||
#获取参数方式,使用raw_input\n\
|
||||
|
|
Loading…
Reference in New Issue