<commit_before>class User < ActiveRecord::Base
  authenticates_with_sorcery!

  include Canable::Cans

  before_save :set_default_course
  after_save :cache_scores

  ROLES = %w(student professor gsi admin)

  ROLES.each do |role|
    scope role.pluralize, -> { where role: role }
  end

  attr_accessor :remember_me, :password, :password_confirmation
  attr_accessible :username, :email, :password, :password_confirmation,
    :avatar_file_name, :role, :first_name, :last_name, :rank, :user_id,
    :display_name, :private_display, :default_course_id, :last_activity_at,
    :last_login_at, :last_logout_at, :team_ids, :courses, :course_ids,
    :shared_badges, :earned_badges, :earned_badges_attributes,
    :remember_me_token, :major, :gpa, :current_term_credits, :accumulated_credits,
    :year_in_school, :state_of_residence, :high_school, :athlete, :act_score, :sat_score,
    :student_academic_history_attributes, :team_role, :course_memberships_attributes,
    :character_profile, :team_id

  #has_secure_password

  scope :alpha, -> { where order: 'last_name ASC' }
  scope :order_by_high_score, -> { order 'course_memberships.score DESC' }
  scope :order_by_low_score, -> { order 'course_memberships.score ASC' }

  has_many :course_memberships
  has_one :student_academic_history, :foreign_key => :student_id, :dependent => :destroy, :class_name => 'StudentAcademicHistory'
  accepts_nested_attributes_for :student_academic_history
  has_many :courses, :through => :course_memberships
  accepts_nested_attributes_for :courses
  accepts_nested_attributes_for :course_memberships
  belongs_to :default_course, :class_name => 'Course'

  has_many :assignment_weights, :foreign_key => :student_id
  has_many :assignments, :through => :grades

  has_many :submissions, :foreign_key => :student_id, :dependent => :destroy
  has_many :created_submissions, :as => :creator
  has_many :grades, :foreign_key => :student_id, :dependent => :destroy
  has_many :graded_grades, foreign_key: :graded_by, :class_name => 'Grade'

  has_many :earned_badges, :foreign_key => :student_id, :dependent => :destroy
  accepts_nested_attributes_for :earned_badges, :reject_if => proc { |attributes| attributes['earned'] != '1' }<commit_msg>Allow mass assigning lti_uid for users<commit_after>class User < ActiveRecord::Base
  authenticates_with_sorcery!

  include Canable::Cans

  before_save :set_default_course
  after_save :cache_scores

  ROLES = %w(student professor gsi admin)

  ROLES.each do |role|
    scope role.pluralize, -> { where role: role }
  end

  attr_accessor :remember_me, :password, :password_confirmation
  attr_accessible :username, :email, :password, :password_confirmation,
    :avatar_file_name, :role, :first_name, :last_name, :rank, :user_id,
    :display_name, :private_display, :default_course_id, :last_activity_at,
    :last_login_at, :last_logout_at, :team_ids, :courses, :course_ids,
    :shared_badges, :earned_badges, :earned_badges_attributes,
    :remember_me_token, :major, :gpa, :current_term_credits, :accumulated_credits,
    :year_in_school, :state_of_residence, :high_school, :athlete, :act_score, :sat_score,
    :student_academic_history_attributes, :team_role, :course_memberships_attributes,
    :character_profile, :team_id, :lti_uid

  #has_secure_password

  scope :alpha, -> { where order: 'last_name ASC' }
  scope :order_by_high_score, -> { order 'course_memberships.score DESC' }
  scope :order_by_low_score, -> { order 'course_memberships.score ASC' }

  has_many :course_memberships
  has_one :student_academic_history, :foreign_key => :student_id, :dependent => :destroy, :class_name => 'StudentAcademicHistory'
  accepts_nested_attributes_for :student_academic_history
  has_many :courses, :through => :course_memberships
  accepts_nested_attributes_for :courses
  accepts_nested_attributes_for :course_memberships
  belongs_to :default_course, :class_name => 'Course'

  has_many :assignment_weights, :foreign_key => :student_id
  has_many :assignments, :through => :grades

  has_many :submissions, :foreign_key => :student_id, :dependent => :destroy
  has_many :created_submissions, :as => :creator
  has_many :grades, :foreign_key => :student_id, :dependent => :destroy
  has_many :graded_grades, foreign_key: :graded_by, :class_name => 'Grade'

  has_many :earned_badges, :foreign_key => :student_id, :dependent => :destroy
  accepts_nested_attributes_for :earned_badges, :reject_if => proc { |attributes| attributes['earned'] != '1' }
{'fraction_non_alphanumeric': 0.10965010028972587, 'fraction_numerical': 0.0004457321149988857, 'mean_word_length': 6.542857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6298924', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1518, 'n_words': 308}