<commit_before>require "association_cache"
require "fileutils"
require "utilities"

class Assessment < ActiveRecord::Base
  # Mass-assignment
  # attr_protected :name

  # Associations
  belongs_to :course
  belongs_to :course_user_datum
  belongs_to :late_penalty, class_name: "Penalty"
  belongs_to :version_penalty, class_name: "Penalty"
  has_many :submissions
  has_many :problems, dependent: :destroy
  has_many :extensions, dependent: :destroy
  has_many :attachments
  has_many :assessment_user_data, dependent: :destroy
  has_one :autograder, dependent: :destroy
  has_one :scoreboard, dependent: :destroy

  # Validations
  validates_uniqueness_of :name, scope: :course_id
  validates_format_of :name, :with => /^[a-zA-Z]+$/, :multiline => true
  validates_length_of :display_name, minimum: 1
  validate :verify_dates_order
  validate :handin_directory_and_filename_or_disable_handins, if: :active?
  validate :handin_directory_exists_or_disable_handins, if: :active?
  validates_numericality_of :max_size, :max_submissions
  validates_numericality_of :version_threshold, only_integer: true,
                                                greater_than_or_equal_to: -1, allow_nil: true
  validates_numericality_of :max_grace_days, only_integer: true,<commit_msg>add validation for Assessment - name can't have leading numeral<commit_after>require "association_cache"
require "fileutils"
require "utilities"

class Assessment < ActiveRecord::Base
  # Mass-assignment
  # attr_protected :name

  # Associations
  belongs_to :course
  belongs_to :course_user_datum
  belongs_to :late_penalty, class_name: "Penalty"
  belongs_to :version_penalty, class_name: "Penalty"
  has_many :submissions
  has_many :problems, dependent: :destroy
  has_many :extensions, dependent: :destroy
  has_many :attachments
  has_many :assessment_user_data, dependent: :destroy
  has_one :autograder, dependent: :destroy
  has_one :scoreboard, dependent: :destroy

  # Validations
  validates_uniqueness_of :name, scope: :course_id
  validates :name, format: { with: /\A[^0-9].*/, message: "can't have leading numeral" }
  validates_length_of :display_name, minimum: 1
  validate :verify_dates_order
  validate :handin_directory_and_filename_or_disable_handins, if: :active?
  validate :handin_directory_exists_or_disable_handins, if: :active?
  validates_numericality_of :max_size, :max_submissions
  validates_numericality_of :version_threshold, only_integer: true,
                                                greater_than_or_equal_to: -1, allow_nil: true
  validates_numericality_of :max_grace_days, only_integer: true,
{'fraction_non_alphanumeric': 0.08042895442359249, 'fraction_numerical': 0.002297970126388357, 'mean_word_length': 5.278846153846154, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3708744', 'n_tokens_mistral': 863, 'n_tokens_neox': 840, 'n_words': 189}