From 213cf48c090268699321573cab4577285901f47e Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 29 Mar 2016 09:02:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E7=9A=84=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E7=BB=93=E6=9E=9C=E6=AF=8F=E8=A1=8C=E5=B0=BE?= =?UTF-8?q?=E9=83=A8=E7=9A=84=E7=A9=BA=E6=A0=BC=E6=89=8D=E7=94=A8=E5=88=AB?= =?UTF-8?q?=E7=9A=84=E7=AC=A6=E5=8F=B7=E4=BB=A3=E6=9B=BF,=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E7=A9=BA=E6=A0=BC=E4=B8=8D=E7=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 34 +++++++++++++++++++--- public/javascripts/homework.js | 6 ++-- 2 files changed, 33 insertions(+), 7 deletions(-) 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/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\ From ed0eb4aff31848f1e661bcbacb90e87ee9468e5e Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Mar 2016 09:24:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/student_work_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = "此时其他同学作品尚未公开" From 0b0f484a5b1f623cf4443a345eb9fd7d777760e2 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Mar 2016 09:50:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=B4=E6=96=87?= =?UTF-8?q?=E6=A4=8D=E7=9A=84=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...29014316_update_one_student_teacher_score.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160329014316_update_one_student_teacher_score.rb 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