Module: WithAssignments
- Extended by:
- ActiveSupport::Concern
- Included in:
- Exercise
- Defined in:
- app/models/concerns/with_assignments.rb
Instance Method Summary collapse
- #assignment_for(user, organization = Organization.current) ⇒ Object
-
#find_assignment_for(user, _organization) ⇒ Object
TODO: When the organization is used in this one, please change guide.pending_exercises TODO: Please do the same on WithAssignmentsBatch.
- #has_messages_for?(user) ⇒ Boolean
- #messages_for(user) ⇒ Object
- #status_for(user) ⇒ Object
Instance Method Details
#assignment_for(user, organization = Organization.current) ⇒ Object
31 32 33 |
# File 'app/models/concerns/with_assignments.rb', line 31 def assignment_for(user, organization=Organization.current) find_assignment_for(user, organization) || user.build_assignment(self, organization) end |
#find_assignment_for(user, _organization) ⇒ Object
TODO: When the organization is used in this one, please change guide.pending_exercises TODO: Please do the same on WithAssignmentsBatch
23 24 25 |
# File 'app/models/concerns/with_assignments.rb', line 23 def find_assignment_for(user, _organization) assignments.find_by(submitter: user) end |
#has_messages_for?(user) ⇒ Boolean
17 18 19 |
# File 'app/models/concerns/with_assignments.rb', line 17 def (user) (user).present? end |
#messages_for(user) ⇒ Object
13 14 15 |
# File 'app/models/concerns/with_assignments.rb', line 13 def (user) assignment_for(user). end |
#status_for(user) ⇒ Object
27 28 29 |
# File 'app/models/concerns/with_assignments.rb', line 27 def status_for(user) assignment_for(user).status if user end |