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.
- #has_messages_for?(user) ⇒ Boolean
- #has_progress_for?(user, organization) ⇒ Boolean
- #messages_for(user) ⇒ Object
- #status_for(user) ⇒ Object
Instance Method Details
#assignment_for(user, organization = Organization.current) ⇒ Object
30 31 32 |
# File 'app/models/concerns/with_assignments.rb', line 30 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
22 23 24 |
# File 'app/models/concerns/with_assignments.rb', line 22 def find_assignment_for(user, organization) assignments.find_by(submitter: user, organization: organization) end |
#has_messages_for?(user) ⇒ Boolean
17 18 19 |
# File 'app/models/concerns/with_assignments.rb', line 17 def (user) (user).present? end |
#has_progress_for?(user, organization) ⇒ Boolean
34 35 36 |
# File 'app/models/concerns/with_assignments.rb', line 34 def has_progress_for?(user, organization) user.present? && find_assignment_for(user, organization).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
26 27 28 |
# File 'app/models/concerns/with_assignments.rb', line 26 def status_for(user) assignment_for(user).status if user end |