Sha256: 4a5d85d161cdc900934cda7c97d713204e52232d8cc7627231a6028de22ef8bf
Contents?: true
Size: 977 Bytes
Versions: 22
Compression:
Stored size: 977 Bytes
Contents
module WithAssignments extend ActiveSupport::Concern # TODO we must avoid _for(user) methods when they # are hidden the assignment object, since an assignment already encapsulates # the exercise-user pair, and many times they impose a performance hit, # since in the normal scenario the assignment object already exists included do has_many :assignments, dependent: :destroy end def messages_for(user) assignment_for(user).messages end def has_messages_for?(user) messages_for(user).present? end # TODO: When the organization is used in this one, please change guide.pending_exercises def find_assignment_for(user, _organization) assignments.find_by(submitter: user) end def status_for(user) assignment_for(user).status if user end def assignment_for(user, organization=Organization.current) find_assignment_for(user, organization) || user.assignments.build(exercise: self, organization: organization) end end
Version data entries
22 entries across 22 versions & 2 rubygems