|
|
@ -251,7 +251,13 @@ module CoursesHelper
|
|
|
|
# 获取课堂的资源数
|
|
|
|
# 获取课堂的资源数
|
|
|
|
def get_attachment_count(course, category_id)
|
|
|
|
def get_attachment_count(course, category_id)
|
|
|
|
identity = current_user.course_identity(course)
|
|
|
|
identity = current_user.course_identity(course)
|
|
|
|
attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id)
|
|
|
|
if category_id.to_i == 0
|
|
|
|
|
|
|
|
attachments = course.attachments
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# children_ids = CourseSecondCategory.where(parent_id: category_id).pluck(:id)
|
|
|
|
|
|
|
|
# category_ids = [category_id] + children_ids
|
|
|
|
|
|
|
|
attachments = course.attachments.joins(:course_second_category).where(course_second_categories: {id: category_id}).or(course.attachments.joins(:course_second_category).where(course_second_categories: {parent_id: category_id}))
|
|
|
|
|
|
|
|
end
|
|
|
|
identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size
|
|
|
|
identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|