mumuki/mumuki-domain

View on GitHub
app/models/concerns/gamified.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Gamified
  def award_experience_points!
    points = net_experience

    if points > 0
      stats = UserStats.stats_for(submitter)
      stats.add_exp!(points)
      stats.save!
    end
  end

  def net_experience
    submitter.currently_in_exam? ? 0 : (submission_status.exp_given - top_submission_status.exp_given)
  end
end