diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 903030ecb..ae33ccb07 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -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,11 +101,14 @@ 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 - logger.debug result + space_replace_1(result["results"].first['output']) + space_replace_1(result["results"].first['result']) + + logger.debug result #-1 默认值 0全部正确并结束 2 超时 -2 编译错误 resultObj[:status] = -1 @@ -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, diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index df5c872f8..4e11e153e 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -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 = "此时其他同学作品尚未公开" diff --git a/db/migrate/20160329014316_update_one_student_teacher_score.rb b/db/migrate/20160329014316_update_one_student_teacher_score.rb new file mode 100644 index 000000000..cf56db220 --- /dev/null +++ b/db/migrate/20160329014316_update_one_student_teacher_score.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index aeabe0ae0..28931468b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 46dfed122..70f00db98 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -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 \n\ int main()\n\ {\n\ @@ -470,7 +470,7 @@ src = '\ //注意\n\ //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\ //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\ - //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),空格用□表示\n\ + //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\ #include \n\ using namespace std;\n\ \n\