<commit_before>class Course < ActiveRecord::Base
  acts_as_paranoid
  acts_as_duplicable

  # default_scope -> { where("courses.is_pending_deletion = 0 ") }

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

  belongs_to :creator, class_name: "User"

  has_many  :announcements, dependent: :destroy
  has_many  :levels, dependent: :destroy
  has_many  :achievements, dependent: :destroy
  has_many  :assessments, dependent: :destroy
  has_many  :questions, through: :assessments
  has_many  :lesson_plan_milestones, dependent: :destroy
  has_many  :lesson_plan_entries, dependent: :destroy
  has_one   :root_folder, dependent: :destroy, conditions: { parent_folder_id: nil }, class_name: "MaterialFolder"
  has_many  :material_folders
  has_many  :comics, dependent: :destroy
  has_many  :tag_groups, dependent: :destroy
  has_many  :tags, through: :tag_groups, dependent: :destroy
  has_many  :taggings, through: :tags
  has_many  :surveys, dependent: :destroy
  has_many  :forums, dependent: :destroy, class_name: 'ForumForum'
  has_many  :tabs, dependent: :destroy
  has_many  :course_themes, dependent: :destroy  # currently only has one though
  has_many  :file_uploads, as: :owner
  has_many  :course_preferences, dependent: :destroy
  has_many  :course_navbar_preferences, 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"

  amoeba do
    include_field [:levels, :tabs, :course_preferences, :course_navbar_preferences,
                   :assessments, :achievements, :lesson_plan_milestones,
                   :lesson_plan_entries, :root_folder, :comics, :tag_groups,
                   :surveys, :forums]
    prepend :title => "Clone of: "
    set :is_publish => false
  end

  #user related
  has_many  :user_courses,  dependent: :destroy
  has_many  :users, through: :usccer_courses
  has_many  :submissions, through: :user_courses
  has_many  :activities, dependent: :destroy
  has_many  :tutorial_groups,        dependent: :destroy
  has_many  :comment_topics,         dependent: :destroy
  has_many  :mass_enrollment_emails, dependent: :destroy
  has_many  :enroll_requests,        dependent: :destroy
  has_many  :tutor_monitorings,      dependent: :destroy
  has_many  :pending_actions

  accepts_nested_attributes_for :course_navbar_preferences
  accepts_nested_attributes_for :trainings
  accepts_nested_attributes_for :missions

  after_create  :initialize_default_settings

  def self.online_course
    Course.where(is_publish: true)
  end<commit_msg>remove used association in course<commit_after>class Course < ActiveRecord::Base
  acts_as_paranoid
  acts_as_duplicable

  # default_scope -> { where("courses.is_pending_deletion = 0 ") }

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

  belongs_to :creator, class_name: "User"

  has_many  :announcements, dependent: :destroy
  has_many  :levels, dependent: :destroy
  has_many  :achievements, dependent: :destroy
  has_many  :assessments, dependent: :destroy
  has_many  :questions, through: :assessments
  has_many  :lesson_plan_milestones, dependent: :destroy
  has_many  :lesson_plan_entries, dependent: :destroy
  has_one   :root_folder, dependent: :destroy, conditions: { parent_folder_id: nil }, class_name: "MaterialFolder"
  has_many  :material_folders
  has_many  :comics, dependent: :destroy
  has_many  :tag_groups, dependent: :destroy
  has_many  :tags, through: :tag_groups, dependent: :destroy
  has_many  :taggings, through: :tags
  has_many  :surveys, dependent: :destroy
  has_many  :forums, dependent: :destroy, class_name: 'ForumForum'
  has_many  :tabs, dependent: :destroy
  has_many  :course_themes, dependent: :destroy  # currently only has one though
  has_many  :file_uploads, as: :owner
  has_many  :course_preferences, dependent: :destroy
  has_many  :course_navbar_preferences, 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"

  amoeba do
    include_field [:levels, :tabs, :course_preferences, :course_navbar_preferences,
                   :assessments, :achievements, :lesson_plan_milestones,
                   :lesson_plan_entries, :root_folder, :comics, :tag_groups,
                   :surveys, :forums]
    prepend :title => "Clone of: "
    set :is_publish => false
  end

  #user related
  has_many  :user_courses,  dependent: :destroy
  has_many  :users, through: :usccer_courses
  has_many  :submissions, through: :user_courses
  has_many  :activities, dependent: :destroy
  has_many  :tutorial_groups,        dependent: :destroy
  has_many  :comment_topics,         dependent: :destroy
  has_many  :mass_enrollment_emails, dependent: :destroy
  has_many  :enroll_requests,        dependent: :destroy
  has_many  :pending_actions

  accepts_nested_attributes_for :course_navbar_preferences
  accepts_nested_attributes_for :trainings
  accepts_nested_attributes_for :missions

  after_create  :initialize_default_settings

  def self.online_course
    Course.where(is_publish: true)
  end
{'fraction_non_alphanumeric': 0.08691358024691358, 'fraction_numerical': 0.0003292181069958848, 'mean_word_length': 4.44932735426009, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5407144', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1936, 'n_words': 445}