Merge branch 'develop' into alan_develop

This commit is contained in:
alan 2016-03-29 10:16:30 +08:00
commit dfe9cb0c68
5 changed files with 52 additions and 9 deletions

View File

@ -55,8 +55,31 @@ class StudentWorkController < ApplicationController
render :json => resultObj
end
#行尾空格替换成□
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,testid:1} #保存每测试一次返回的结果
@ -78,10 +101,13 @@ class StudentWorkController < ApplicationController
result = test_realtime_ex(test, params[:src])
if result["status"].to_i != -2
result["results"].first['output'] = result["results"].first['output'].gsub(" ","")
result["results"].first['result'] = result["results"].first['result'].gsub(" ","")
#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 编译错误
@ -108,7 +134,7 @@ 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,

View File

@ -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 = "此时其他同学作品尚未公开"

View File

@ -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

View File

@ -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

View File

@ -426,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\
@ -450,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\
@ -470,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\