Add waiting room to create programming groups (#1919)

Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
This commit is contained in:
Kira Grammel
2023-09-21 15:07:10 +02:00
committed by GitHub
parent 1dfc306e76
commit 9f837412c7
15 changed files with 174 additions and 48 deletions

View File

@ -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)') }

View 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

View File

@ -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

View File

@ -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