diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8f024c1c6..0ee83e839 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -238,7 +238,9 @@ module CoursesHelper # 获取课堂的资源数 def get_attachment_count(course, category_id) - category_id.to_i == 0 ? course.attachments.size : course.attachments.where(course_second_category_id: category_id).size + identity = current_user.course_identity(course) + attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id) + identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size end # 获取课堂的视频数 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3ff9a6a90..1a9b50c3b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ApplicationRecord scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} + scope :published, -> {where(is_publish: 1)} validates_length_of :description, maximum: 100, message: "不能超过100个字符"