<commit_before>class Registration < ActiveRecord::Base
  attr_accessible :course_id, :teacher, :user_id
  
  belongs_to :user
  belongs_to :course

  validates :user_id,   :presence => true
  validates :course_id, :presence => true

  validates :user_id, :uniqueness => { :scope => :course_id }

  def answers_done
    qs = course.questions
    done = 0
    qs.each do |qq|
      qq.answers.where(user_id: user_id).each do |aa|
        done += 1 if aa.answer == aa.correct_answer
      end
    end
    "#{done} / #{qs.size}"
  end

  def submissions_done
    as = course.assignments
    score = 0
    total = 0
    as.each do |aa|
      total += aa.points_available
      score += aa.best_score_for(user)
    end
    "#{score} / #{total}"
  end
end
<commit_msg>Round student grades on course screen (issue #14).<commit_after>class Registration < ActiveRecord::Base
  attr_accessible :course_id, :teacher, :user_id
  
  belongs_to :user
  belongs_to :course

  validates :user_id,   :presence => true
  validates :course_id, :presence => true

  validates :user_id, :uniqueness => { :scope => :course_id }

  def answers_done
    qs = course.questions
    done = 0
    qs.each do |qq|
      qq.answers.where(user_id: user_id).each do |aa|
        done += 1 if aa.answer == aa.correct_answer
      end
    end
    "#{done} / #{qs.size}"
  end

  def submissions_done
    as = course.assignments
    score = 0
    total = 0
    as.each do |aa|
      total += aa.points_available
      score += aa.best_score_for(user)
    end
    "#{score.round(1)} / #{total.round(1)}"
  end
end

{'fraction_non_alphanumeric': 0.11794546607482562, 'fraction_numerical': 0.007609384908053266, 'mean_word_length': 2.7661097852028638, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2980731', 'n_tokens_mistral': 583, 'n_tokens_neox': 549, 'n_words': 141}