diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 1e51d7dd2..8b1c8ba32 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -79,7 +79,8 @@ class FilesController < ApplicationController @result = find_course_attache q,@course,sort @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 - @tag_list = attachment_tag_list @result + + @tag_list = get_course_tag_list @course end #rescue Exception => e # #render 'stores' @@ -541,7 +542,7 @@ class FilesController < ApplicationController @result = visable_attachemnts @result @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} @searched_attach = paginateHelper @result,10 - @tag_list = attachment_tag_list @result + @tag_list = get_course_tag_list @course respond_to do |format| format.js diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d4399e464..f1c9451bf 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -223,11 +223,7 @@ class TagsController < ApplicationController if @obj && @object_flag == '6' && @obj.container.kind_of?(Course) @course = @obj.container - all_attachments = @course.attachments.select{|attachment| attachment.is_public? || - (attachment.container_type == "Course" && User.current.member_of_course?(@course))|| - attachment.author_id == User.current.id - } - @tag_list = attachment_tag_list all_attachments + @tag_list = get_course_tag_list @course end # end end @@ -274,11 +270,7 @@ class TagsController < ApplicationController end if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course) @course = @obj.container - all_attachments = @course.attachments.select{|attachment| attachment.is_public? || - (attachment.container_type == "Course" && User.current.member_of_course?(@course))|| - attachment.author_id == User.current.id - } - @tag_list = attachment_tag_list all_attachments + @tag_list = @tag_list = get_course_tag_list @course end respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5782d4bc8..9c9c96ce5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2106,4 +2106,14 @@ module ApplicationHelper end tag_list.sort {|a,b| b[1]<=>a[1]} end + + #获取课程资源的TAG云 + def get_course_tag_list course + all_attachments = course.attachments.select{|attachment| attachment.is_public? || + (attachment.container_type == "Course" && User.current.member_of_course?(course))|| + attachment.author_id == User.current.id + } + tag_list = attachment_tag_list all_attachments + tag_list + end end