diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 408783934..f4ba5040e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -736,4 +736,14 @@ module CoursesHelper "未启用匿评".html_safe end end + + def visable_attachemnts_incourse course + result = [] + course.attachments.each do |attachment| + if attachment.is_public? || User.current.member_of_course?(course) + result << attachment + end + end + result + end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 08b17ea7a..503e3d6ed 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -108,16 +108,6 @@ module FilesHelper result end - def visable_attachemnts_incourse attachments - result = [] - attachments.each do |attachment| - if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id - result << attachment - end - end - result - end - def visable_attachemnts_insite attachments,course result = [] attachments.each do |attachment| diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e787cfa54..25b08ce7d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,6 +1,7 @@ <% course_model %> <% teacher_num = teacherCount(@course) %> <% student_num = studentCount(@course) %> +<% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> @@ -94,7 +95,7 @@ <%= l(:label_account_identity_student)%>(<%= course_student_link student_num %>) - <%= l(:project_module_attachments)%>(<%= link_to @course.attachments.count, course_files_path(@course), :class => 'info_foot_num c_blue' %>) + <%= l(:project_module_attachments)%>(<%= link_to course_file_num, course_files_path(@course), :class => 'info_foot_num c_blue' %>)
@@ -125,7 +126,9 @@ <%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>