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