From 183892304162fe91ad89d63af71809c2486dc8da Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Mar 2020 20:28:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_common.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index a6a919981..58a420581 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -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} - end + 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 + 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