diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 055c59f06..5252e5884 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -522,6 +522,7 @@ class UsersController < ApplicationController @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset + @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids] #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,7 respond_to do |format| @@ -555,6 +556,7 @@ class UsersController < ApplicationController @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset + @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids] #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,7 respond_to do |format| @@ -586,6 +588,7 @@ class UsersController < ApplicationController @atta_count = @attachments.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset + @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids] #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,7 respond_to do |format| @@ -596,8 +599,8 @@ class UsersController < ApplicationController #将资源批量引入 def import_resources_to_homework @attachments = [] - unless params[:checkbox1].nil? || params[:checkbox1].blank? - params[:checkbox1].each do |id| + unless session[:seleted_resource_ids].nil? || session[:seleted_resource_ids].blank? + session[:seleted_resource_ids].each do |id| atta = Attachment.find(id) att_copy = atta.copy att_copy.container_id = nil @@ -608,11 +611,23 @@ class UsersController < ApplicationController @attachments << att_copy end end + session[:seleted_resource_ids] = [] #保存后清空 respond_to do |format| format.js end end + # ajax 用session保存选择的资源id + def store_selected_resource + session[:seleted_resource_ids] = [] if session[:seleted_resource_ids].nil? + if params[:save] == 'y' + session[:seleted_resource_ids] << params[:res_id] + else + session[:seleted_resource_ids].delete( params[:res_id]) + end + render :nothing => true + end + include CoursesHelper def user_courses diff --git a/app/views/users/_homework_ref_resources_list.html.erb b/app/views/users/_homework_ref_resources_list.html.erb new file mode 100644 index 000000000..356e412e7 --- /dev/null +++ b/app/views/users/_homework_ref_resources_list.html.erb @@ -0,0 +1,25 @@ + +<% if attachments.nil? || attachments.empty? %> + + + +<% else %> + <% attachments.each do |attach| %> +