学生视角的资源不显示未发布数量

courseware
cxt 5 years ago
parent 0b1797c6bd
commit 89875130b4

@ -238,7 +238,9 @@ module CoursesHelper
# 获取课堂的资源数 # 获取课堂的资源数
def get_attachment_count(course, category_id) 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 end
# 获取课堂的视频数 # 获取课堂的视频数

@ -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 :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 :search_by_container, -> (ids) {where(container_id: ids)}
scope :unified_setting, -> {where("unified_setting = ? ", 1)} scope :unified_setting, -> {where("unified_setting = ? ", 1)}
scope :published, -> {where(is_publish: 1)}
validates_length_of :description, maximum: 100, message: "不能超过100个字符" validates_length_of :description, maximum: 100, message: "不能超过100个字符"

Loading…
Cancel
Save