class EcCourse < ApplicationRecord
  belongs_to :ec_year

  # 课程目标
  has_many :ec_course_targets, dependent: :destroy
  has_many :ec_graduation_subitem_course_targets, through: :ec_course_targets
  # 课程负责教师
  has_many :ec_course_users
  has_many :course_managers, through: :ec_course_users, class_name: 'User'
  # 课程考核标准
  has_many :ec_course_evaluations, dependent: :destroy
  # 课程等级
  has_many :ec_score_levels, dependent: :destroy
  # 课程支撑
  has_many :ec_course_supports, dependent: :destroy
  has_many :ec_graduation_subitems, through: :ec_course_supports
  # 达成评价
  has_many :ec_course_student_scores, dependent: :destroy
  # 工程课堂和educoder课堂关联
  has_many :ec_major_courses, dependent: :destroy
  has_many :courses, through: :ec_major_courses

  # 课程目标达成方法
  # has_many :ec_course_achievement_methods

  accepts_nested_attributes_for :ec_course_targets, :ec_score_levels, allow_destroy: true
end