From 0d82cc7a2c4b3559f99b502be0740e06a4912335 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 23 Jul 2019 21:22:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=80=89=E7=94=A8=E9=A2=98=E5=BA=93?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/question_banks_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index e30065d09..8f295fa95 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -147,15 +147,17 @@ class QuestionBanksController < ApplicationController new_homework.homework_detail_group.base_on_project = homework.base_on_project end # 附件 + logger.info("######attachments: #{homework.attachments.count}") homework.attachments.try(:each) do |attachment| att = attachment.copy att.container_id = nil att.container_type = nil att.author_id = homework.user_id att.copy_from = attachment.id - att.save + att.save! new_homework.attachments << att end + logger.info("######new_homework.attachments: #{new_homework.attachments.count}") if new_homework.save new_homework_detail_manual.save if new_homework_detail_manual From a5ecdac73da1afaf432965db194dde247349cb6a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 23 Jul 2019 21:26:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index be4448a92..9edb6bb9d 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -830,8 +830,6 @@ private def is_shixun_reset?(games, min_challenges, current_myshixun) # 用户在申请发布之前,是否玩过实训 TODO: 重置的字段应该迁移到myshixuns表比较合适 modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1) - games.size != min_challenges.size || - games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first} || - modify_shixun + games.size != min_challenges.size || modify_shixun end end From 86f872e6271221fcc1c65b308491b0b8a809a4bd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 23 Jul 2019 21:41:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E9=80=89=E7=94=A8=E9=A2=98=E5=BA=93=E9=99=84=E4=BB=B6=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/question_banks_controller.rb | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 8f295fa95..76600c6a2 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -148,22 +148,21 @@ class QuestionBanksController < ApplicationController end # 附件 logger.info("######attachments: #{homework.attachments.count}") - homework.attachments.try(:each) do |attachment| - att = attachment.copy - att.container_id = nil - att.container_type = nil - att.author_id = homework.user_id - att.copy_from = attachment.id - att.save! - new_homework.attachments << att - end - logger.info("######new_homework.attachments: #{new_homework.attachments.count}") - - if new_homework.save + if new_homework.save! + homework.attachments.try(:each) do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.author_id = homework.user_id + att.copy_from = attachment.id + att.save! + new_homework.attachments << att + end + logger.info("######new_homework.attachments: #{new_homework.attachments.count}") new_homework_detail_manual.save if new_homework_detail_manual new_homework.homework_detail_group.save if new_homework.homework_detail_group HomeworksService.new.create_works_list(new_homework, course) - homework.update_column(:quotes, homework.quotes+1) + homework.update_column(:quotes, homework.quotes + 1) end new_homework end