资源的父目录需统计子目录个数

courseware
cxt 5 years ago
parent 54c7efd94c
commit 8a410b569b

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

Loading…
Cancel
Save