<commit_before>class GradingConflict < ApplicationRecord

  belongs_to :grader_user, class_name: "User"
  belongs_to :gradee_user, class_name: "User"
  belongs_to :course

   # TODO: What else needs to be validated?
  validate :users_have_proper_roles


  # N/A -> Boolean 
  # Ensures that the :grader_user is a grader and the :gradee_user 
  # is a normal student
  def users_have_proper_roles
    return (self.grader_user.course_grader?(course) || 
      self.grader_user.course_assistant?(course)) &&
      self.gradee_user.course_student?(course)
  end
end<commit_msg>Fixed validation for grader/gradee roles for GradingConflict model.<commit_after>class GradingConflict < ApplicationRecord

  belongs_to :grader_user, class_name: "User"
  belongs_to :gradee_user, class_name: "User"
  belongs_to :course

  # TODO: What else needs to be validated?
  validates :grader_user, presence: true
  validates :gradee_user, presence: true
  validates :course, presence: true
  validate :users_must_have_correct_roles


  def users_must_have_correct_roles
    unless self.users_have_proper_roles?
      errors.add(:base, "GradingConflict's grader_user is not a grader OR gradee_user is not a student.")
    end
  end

  # N/A -> Boolean 
  # Ensures that the :grader_user is a grader and the :gradee_user 
  # is a normal student
  def users_have_proper_roles?
    return (self.grader_user.course_grader?(course) || 
      self.grader_user.course_assistant?(course)) &&
      self.gradee_user.course_student?(course)
  end
end
{'fraction_non_alphanumeric': 0.07818659658344283, 'fraction_numerical': 0.0, 'mean_word_length': 4.4784172661870505, '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': '2110102', 'n_tokens_mistral': 520, 'n_tokens_neox': 503, 'n_words': 129}