班级新建作业,加入题库时,没有将附件一起加入
This commit is contained in:
parent
e28d635630
commit
524dd85409
|
@ -695,7 +695,7 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.container.board.course)
|
||||
@course = @attachment.container.board.course
|
||||
else
|
||||
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest'
|
||||
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest' || @attachment.container_type == 'HomeworkBank'
|
||||
@project = @attachment.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1269,14 +1269,14 @@ class UsersController < ApplicationController
|
|||
#@homework.end_time = homework.end_time
|
||||
@homework.homework_type = homework.homework_type
|
||||
#@homework.course_id = homework.course_id
|
||||
# homework.attachments.each do |attachment|
|
||||
# att = attachment.copy
|
||||
# att.container_id = nil
|
||||
# att.container_type = nil
|
||||
# att.copy_from = attachment.id
|
||||
# att.save
|
||||
# @homework.attachments << att
|
||||
# end
|
||||
homework.attachments.each do |attachment|
|
||||
att = attachment.copy
|
||||
att.container_id = nil
|
||||
att.container_type = nil
|
||||
att.copy_from = attachment.id
|
||||
att.save
|
||||
@homework.attachments << att
|
||||
end
|
||||
|
||||
#if homework_detail_programing
|
||||
if homework.homework_type == 2
|
||||
|
|
|
@ -2532,6 +2532,8 @@ module ApplicationHelper
|
|||
candown = true
|
||||
elsif attachment.container.class.to_s=="ContestantWork"
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s=="HomeworkBank"
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s=="BlogComment" #博客资源允许下载
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s=="Memo" #论坛资源允许下载
|
||||
|
@ -4149,6 +4151,15 @@ def add_to_homework_bank_f homework
|
|||
homework_bank.max_num = homework.homework_detail_group.max_num
|
||||
homework_bank.base_on_project = homework.homework_detail_group.base_on_project
|
||||
end
|
||||
homework.attachments.each do |attachment|
|
||||
att = attachment.copy
|
||||
att.container_id = nil
|
||||
att.container_type = nil
|
||||
att.author_id = homework_bank.user_id
|
||||
att.copy_from = attachment.id
|
||||
att.save
|
||||
homework_bank.attachments << att
|
||||
end
|
||||
homework_bank
|
||||
end
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
分组人数:<%=@homework.min_num %> - <%=@homework.max_num %>人
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<div class="mt10" style="font-weight:normal;">
|
||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @homework} %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class AddAttachToHomeworkBank < ActiveRecord::Migration
|
||||
def change
|
||||
HomeworkBank.all.each do |homework_bank|
|
||||
homework = homework_bank.homework_common_id.nil? ? nil : HomeworkCommon.where(:id =>homework_bank.homework_common_id).first
|
||||
unless homework.nil?
|
||||
homework.attachments.each do |attachment|
|
||||
att = attachment.copy
|
||||
att.container_id = nil
|
||||
att.container_type = nil
|
||||
att.author_id = homework_bank.user_id
|
||||
att.copy_from = attachment.id
|
||||
att.save
|
||||
homework_bank.attachments << att
|
||||
homework_bank.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue