json.extract! @ec_course, :id, :name, :ec_year_id, :complete_target_count

course_target_count = @ec_course.ec_course_targets.count
json.course_target_count course_target_count
json.course_evaluation_count @ec_course.ec_course_evaluations.count
json.course_achievement_method_count @ec_course.ec_course_achievement_methods.count

json.graduation_subitem_count EcGraduationSubitemCourseTarget.joins(:ec_course_target)
                                .where(ec_course_targets: { ec_course_id: @ec_course.id })
                                .count('distinct ec_graduation_subitem_id')
json.completed_graduation_subitem_count EcCourseSupport.joins(:ec_graduation_requirement_calculation)
                                          .where(ec_course_id: @ec_course.id)
                                          .where(ec_graduation_requirement_calculations: { status: 1 })
                                          .count('distinct ec_graduation_subitem_id')
# 达成状态
status = if course_target_count.zero?
           ''
         else
           ec_course.complete_target_count == course_target_count ? 'achieved' : 'not_achieved'
         end
json.status status

json.course_managers @ec_course.course_managers, partial: 'ecs/shared/user', as: :user