@ -58,6 +58,7 @@ class UsersController < ApplicationController
helper :sort
helper :attachments
include SortHelper
include ApplicationHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
@ -425,9 +426,9 @@ class UsersController < ApplicationController
homework = HomeworkCommon . find params [ :homework ] . to_i
if ! params [ :search ] . nil?
search = " % #{ params [ :search ] . to_s . strip . downcase } % "
@course = @user . courses . where ( " #{ Course . table_name } .id != #{ homework . course_id } and #{ Course . table_name } .id = #{ params [ :search ] . to_i } or #{ Course . table_name } .name like :p " , :p = > search ) . select { | course | @user . allowed_to? ( :as_teacher , course ) }
@course = @user . courses . where ( " is_delete = 0 and #{ Course . table_name } .id != #{ homework . course_id } and #{ Course . table_name } .id = #{ params [ :search ] . to_i } or #{ Course . table_name } .name like :p " , :p = > search ) . select { | course | @user . allowed_to? ( :as_teacher , course ) }
else
@course = @user . courses . where ( " #{ Course . table_name } .id != #{ homework . course_id } " ) . select { | course | @user . allowed_to? ( :as_teacher , course ) }
@course = @user . courses . where ( " is_delete = 0 and #{ Course . table_name } .id != #{ homework . course_id } " ) . select { | course | @user . allowed_to? ( :as_teacher , course ) }
end
@search = params [ :search ]
#这里仅仅是传递需要发送的资源id
@ -690,6 +691,11 @@ class UsersController < ApplicationController
end
student_work . save
homework . update_attributes ( :updated_at = > Time . now )
update_course_activity ( homework . class , homework . id )
update_user_activity ( homework . class , homework . id )
update_org_activity ( homework . class , homework . id )
flash [ :notice ] = l ( :notice_successful_create )
redirect_to student_work_index_url ( :homework = > params [ :homework ] )
else
@ -1693,17 +1699,17 @@ class UsersController < ApplicationController
@flag = true
if params [ :send_id ] . present?
send_id = params [ :send_id ]
ori = Attachment . find_by_id ( send_id )
@ ori = Attachment . find_by_id ( send_id )
course_ids = params [ :course_ids ]
if course_ids . nil?
@flag = false
end
unless course_ids . nil?
course_ids . each do | id |
next if ori. blank?
next if @ ori. blank?
@exist = false
Course . find ( id ) . attachments . each do | att | #如果课程中包含该资源
if att . id == ori. id || ( ! att . copy_from . nil? && ! ori. copy_from . nil? && att . copy_from == ori. copy_from ) || att . copy_from == ori . id || att . id == ori. copy_from
if att . id == @ ori. id || ( ! att . copy_from . nil? && ! @ ori. copy_from . nil? && att . copy_from == @ ori. copy_from ) || att . copy_from == @ori . id || att . id == @ ori. copy_from
att . created_on = Time . now
att . save
@exist = true
@ -1711,21 +1717,21 @@ class UsersController < ApplicationController
end
end
next if @exist
attach_copied_obj = ori. copy
attach_copied_obj . tag_list . add ( ori. tag_list ) # tag关联
attach_copied_obj = @ ori. copy
attach_copied_obj . tag_list . add ( @ ori. tag_list ) # tag关联
attach_copied_obj . container = Course . find ( id )
attach_copied_obj . created_on = Time . now
attach_copied_obj . author_id = User . current . id
attach_copied_obj . is_public = 0
attach_copied_obj . copy_from = ori . copy_from . nil? ? ori . id : ori. copy_from #发送要添加copy_from
attach_copied_obj . copy_from = @ori . copy_from . nil? ? @ori . id : @ ori. copy_from #发送要添加copy_from
if attach_copied_obj . attachtype == nil
attach_copied_obj . attachtype = 4
end
if attach_copied_obj . save
# 更新引用次数
quotes = ori. quotes . to_i + 1
ori. update_attribute ( :quotes , quotes ) unless ori. nil?
ori. forwards << Forward . new ( :to_type = > attach_copied_obj . class . name , :to_id = > attach_copied_obj . id , :created_at = > Time . now )
quotes = @ ori. quotes . to_i + 1
@ ori. update_attribute ( :quotes , quotes ) unless @ ori. nil?
@ ori. forwards << Forward . new ( :to_type = > attach_copied_obj . class . name , :to_id = > attach_copied_obj . id , :created_at = > Time . now )
end
@save_message = attach_copied_obj . errors . full_messages
end
@ -1837,6 +1843,7 @@ class UsersController < ApplicationController
Project . find ( project_id ) . project_score . attach_num + 1 )
end
end
@ori = ori
end
elsif params [ :send_ids ] . present?
send_ids = params [ :send_ids ] . split ( " " )
@ -1941,6 +1948,7 @@ class UsersController < ApplicationController
end
end
end
@ori = ori
elsif params [ :send_ids ] . present?
send_ids = params [ :send_ids ] . split ( " " )
subfield_id = params [ :subfield ]