作业子目录

PCqiandao
cxt 5 years ago
parent ab15b118ec
commit 1838923041

@ -69,17 +69,18 @@ class HomeworkCommon < ApplicationRecord
# 作业对应的子目录/父目录名称
def category_info
case self.homework_type
when 'normal'
{category_id: course.common_course_modules.first.try(:id), category_name: course.common_course_modules.first.try(:module_name), main: 1}
when 'group'
{category_id: course.group_course_modules.first.try(:id), category_name: course.group_course_modules.first.try(:module_name), main: 1}
when 'practice'
if self.course_second_category.present?
{category_id: self.course_second_category.try(:id), category_name: self.course_second_category.try(:name), main: 0}
else
{category_id: course.shixun_course_modules.take.try(:id), category_name: course.shixun_course_modules.take.try(:module_name), main: 1}
course_module = case homework_type
when 'normal'
course.common_course_modules.take
when 'group'
course.group_course_modules.take
when 'practice'
course.shixun_course_modules.take
end
{category_id: course_module.try(:id), category_name: course_module.try(:module_name), main: 1}
end
end

Loading…
Cancel
Save