<commit_before>module CourseLock
  def self.included(base)
    base.class_eval do
      belongs_to :course

      return if ENV["RAILS_ENV"] == "test"
      default_scope {
        if Course.current.nil?
          raise NoCourseAvailable
        else
          if Course.current.replica && [Exercise, PeerReview::Challenge, MultipleChoices::Questionnaire, Resource, ResourceCategory, Event, Faq].include?(base)
            # replica and entity from parent
            where(course_id: Course.current.parent_course_id)
          elsif Course.current.replica && [Post].include?(base)
            # replica and entity from parent or myself
            where(course_id: [Course.current.id, Course.current.parent_course_id])
          elsif Course.current.replicas.size > 0 && ![Post, Exercise, MultipleChoices::Questionnaire, Faq, Resource, ResourceCategory, Event].include?(base)
            # parent and entity from me or replicas
            where(course_id: Course.current.family_ids)
          else
            # any other case<commit_msg>Fixed issue when saving a challenge<commit_after>module CourseLock
  def self.included(base)
    base.class_eval do
      belongs_to :course

      return if ENV["RAILS_ENV"] == "test"
      default_scope {
        if Course.current.nil?
          raise NoCourseAvailable
        else
          if Course.current.replica && [Exercise, PeerReview::Challenge, MultipleChoices::Questionnaire, Resource, ResourceCategory, Event, Faq].include?(base)
            # replica and entity from parent
            where(course_id: Course.current.parent_course_id)
          elsif Course.current.replica && [Post].include?(base)
            # replica and entity from parent or myself
            where(course_id: [Course.current.id, Course.current.parent_course_id])
          elsif Course.current.replicas.size > 0 && ![Post, Exercise, PeerReview::Challenge, MultipleChoices::Questionnaire, Faq, Resource, ResourceCategory, Event].include?(base)
            # parent and entity from me or replicas
            where(course_id: Course.current.family_ids)
          else
            # any other case
{'fraction_non_alphanumeric': 0.0908235294117647, 'fraction_numerical': 0.0009411764705882353, 'mean_word_length': 2.803220035778175, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6466961', 'n_tokens_mistral': 594, 'n_tokens_neox': 571, 'n_words': 145}