Add events for pair programming study
This commit is contained in:

committed by
Sebastian Serth

parent
d1d5b0df6f
commit
79422225a8
@@ -3,8 +3,19 @@
|
||||
class Event < ApplicationRecord
|
||||
include Creation
|
||||
belongs_to :exercise
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
belongs_to :file, class_name: 'CodeOcean::File', optional: true
|
||||
belongs_to :study_group, optional: true
|
||||
belongs_to :programming_group, optional: true
|
||||
|
||||
validates :category, presence: true
|
||||
validates :data, presence: true
|
||||
|
||||
# We temporary allow an event to be stored without data.
|
||||
# This is useful if the category (together with the user and exercise) is already enough.
|
||||
validates :data, presence: true, if: -> { %w[pp_start_chat pp_invalid_partners pp_work_alone].exclude?(category) }
|
||||
|
||||
before_validation :data_presence
|
||||
|
||||
def data_presence
|
||||
self.data = data.presence
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user