Add waiting room to create programming groups (#1919)
Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
This commit is contained in:
@ -32,6 +32,7 @@ class Exercise < ApplicationRecord
|
||||
has_many :external_users, source: :contributor, source_type: 'ExternalUser', through: :submissions
|
||||
has_many :internal_users, source: :contributor, source_type: 'InternalUser', through: :submissions
|
||||
has_many :programming_groups
|
||||
has_many :pair_programming_waiting_users
|
||||
|
||||
scope :with_submissions, -> { where('id IN (SELECT exercise_id FROM submissions)') }
|
||||
|
||||
|
25
app/models/pair_programming_waiting_user.rb
Normal file
25
app/models/pair_programming_waiting_user.rb
Normal file
@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PairProgrammingWaitingUser < ApplicationRecord
|
||||
include Creation
|
||||
|
||||
belongs_to :exercise
|
||||
belongs_to :programming_group, optional: true
|
||||
|
||||
enum status: {
|
||||
waiting: 0,
|
||||
joined_pg: 1,
|
||||
disconnected: 2,
|
||||
worked_alone: 3,
|
||||
created_pg: 4,
|
||||
}, _prefix: true
|
||||
|
||||
validates :user_id, uniqueness: {scope: %i[exercise_id user_type]}
|
||||
validates :programming_group_id, presence: true, if: -> { status_joined_pg? || status_created_pg? }
|
||||
|
||||
after_save :capture_event
|
||||
|
||||
def capture_event
|
||||
Event.create(category: 'pp_matching', user:, exercise:, data: status.to_s)
|
||||
end
|
||||
end
|
@ -12,6 +12,7 @@ class ProgrammingGroup < ApplicationRecord
|
||||
has_many :events
|
||||
has_many :events_synchronized_editor, class_name: 'Event::SynchronizedEditor'
|
||||
has_many :pair_programming_exercise_feedbacks
|
||||
has_many :pair_programming_waiting_users
|
||||
belongs_to :exercise
|
||||
|
||||
validate :min_group_size
|
||||
|
@ -25,6 +25,7 @@ class User < ApplicationRecord
|
||||
has_many :events
|
||||
has_many :events_synchronized_editor, class_name: 'Event::SynchronizedEditor'
|
||||
has_many :pair_programming_exercise_feedbacks
|
||||
has_many :pair_programming_waiting_users
|
||||
has_one :codeharbor_link, dependent: :destroy
|
||||
accepts_nested_attributes_for :user_proxy_exercise_exercises
|
||||
|
||||
|
Reference in New Issue
Block a user