<commit_before>class Course < ActiveRecord::Base
  acts_as_paranoid

  # default_scope where(:is_pending_deletion => false)

  attr_accessible :creator_id, :description, :logo_url, :title, :is_publish,
                  :is_active, :is_open, :start_at, :end_at, :course_navbar_preferences_attributes

  before_create :populate_preference
  after_create :create_materials_root

  belongs_to :creator, class_name: "User"

  has_many  :user_courses,  dependent: :destroy
  has_many  :users, through: :user_courses

  has_many  :assessments, dependent: :destroy
  has_many  :missions, class_name: "Assessment::Mission", through: :assessments,
            source: :as_assessment, source_type: "Assessment::Mission" do
    def published
      where("assessments.published = ?", true)
    end
  end

  has_many  :trainings, class_name: "Assessment::Training", through: :assessments,
            source: :as_assessment, source_type: "Assessment::Training"

  has_many :submissions,          through: :user_courses

  has_many :announcements,     dependent: :destroy
  has_many :lesson_plan_entries, dependent: :destroy<commit_msg>allow nested access and updates of missions and trainings in course model<commit_after>class Course < ActiveRecord::Base
  acts_as_paranoid

  # default_scope where(:is_pending_deletion => false)

  attr_accessible :creator_id, :description, :logo_url, :title, :is_publish,
                  :is_active, :is_open, :start_at, :end_at

  attr_accessible :course_navbar_preferences_attributes,
                  :missions_attributes,
                  :trainings_attributes

  before_create :populate_preference
  after_create :create_materials_root

  belongs_to :creator, class_name: "User"

  has_many  :user_courses,  dependent: :destroy
  has_many  :users, through: :user_courses

  has_many  :assessments, dependent: :destroy
  has_many  :missions, class_name: "Assessment::Mission", through: :assessments,
            source: :as_assessment, source_type: "Assessment::Mission" do
    def published
      where("assessments.published = ?", true)
    end
  end
  accepts_nested_attributes_for :missions

  has_many  :trainings, class_name: "Assessment::Training", through: :assessments,
            source: :as_assessment, source_type: "Assessment::Training"

  accepts_nested_attributes_for :trainings

  has_many :submissions,          through: :user_courses

  has_many :announcements,     dependent: :destroy
  has_many :lesson_plan_entries, dependent: :destroy
{'fraction_non_alphanumeric': 0.0887906789875452, 'fraction_numerical': 0.0, 'mean_word_length': 4.472527472527473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1028902', 'n_tokens_mistral': 806, 'n_tokens_neox': 766, 'n_words': 171}