module Sis module Core class CourseAssignment < ApplicationRecord belongs_to :course_offering belongs_to :section belongs_to :instructor belongs_to :lab_instructor, class_name: 'Sis::Core::Instructor', optional: true belongs_to :tutorial_instructor, class_name: 'Sis::Core::Instructor', optional: true delegate(:course_code, to: :course_offering, prefix: false) delegate(:course_title, to: :course_offering, prefix: false) delegate(:course_ects, to: :course_offering, prefix: false) delegate(:course_credit_hours, to: :course_offering, prefix: false) delegate(:course_id, to: :course_offering, prefix: false) delegate(:course_lecture_hours, to: :course_offering, prefix: false) delegate(:course_lab_hours, to: :course_offering, prefix: false) delegate(:course_tutorial_hours, to: :course_offering, prefix: false) delegate(:first_name, to: :instructor, prefix: true, allow_nil: true) delegate(:middle_name, to: :instructor, prefix: true, allow_nil: true) delegate(:last_name, to: :instructor, prefix: true, allow_nil: true) delegate(:first_name, to: :lab_instructor, prefix: true, allow_nil: true) delegate(:middle_name, to: :lab_instructor, prefix: true, allow_nil: true) delegate(:last_name, to: :lab_instructor, prefix: true, allow_nil: true) delegate(:first_name, to: :tutorial_instructor, prefix: true, allow_nil: true) delegate(:middle_name, to: :tutorial_instructor, prefix: true, allow_nil: true) delegate(:last_name, to: :tutorial_instructor, prefix: true, allow_nil: true) def instructor_full_name "#{instructor_first_name} #{instructor_middle_name} #{instructor_last_name}" end def lab_instructor_full_name "#{lab_instructor_first_name} #{lab_instructor_middle_name} #{lab_instructor_last_name}" end def tutorial_instructor_full_name "#{tutorial_instructor_first_name} #{tutorial_instructor_middle_name} #{tutorial_instructor_last_name}" end end end end