From f5cfd7258d32493b93143c3e628875e5a40f0ec7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 1 Aug 2015 14:27:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=97=B6=EF=BC=8C=E5=AF=B9=E5=B7=B2=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E3=80=81=E6=9C=AA=E9=80=9A=E8=BF=87=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=98=BE=E7=A4=BA=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=9A=84=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 4 +++- app/models/homework_test.rb | 2 +- .../_homework_detail_programing_form.html.erb | 12 ++++++++++-- db/migrate/20150801034945_change_result_default.rb | 9 +++++++++ db/schema.rb | 8 ++++---- 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20150801034945_change_result_default.rb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index e3424707f..6f2ecef0b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -223,17 +223,19 @@ class HomeworkCommonController < ApplicationController homework_test = HomeworkTest.find id homework_test.destroy if homework_test end - if params[:input] && params[:output] + if params[:input] && params[:output] && params[:result] params[:input].each do |k,v| if params[:output].include? k homework_test = HomeworkTest.find_by_id k if homework_test #已存在的测试,修改 homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] else #不存在的测试,增加 homework_test = HomeworkTest.new homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] homework_test.homework_common = @homework end homework_test.save diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index 4ed290ecd..df2848194 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -1,5 +1,5 @@ class HomeworkTest < ActiveRecord::Base - attr_accessible :input, :output, :homework_common_id + attr_accessible :input, :output, :homework_common_id,:result,:error_msg belongs_to :homework_common has_many :student_work_test diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 7c66df057..22ca4cac7 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -96,8 +96,16 @@