Enable interventions for ProgrammingGroups and add indices
This commit is contained in:
@ -2,12 +2,18 @@
|
||||
|
||||
class Intervention < ApplicationRecord
|
||||
has_many :user_exercise_interventions
|
||||
has_many :users, through: :user_exercise_interventions, source_type: 'ExternalUser'
|
||||
has_many :external_users, through: :user_exercise_interventions, source: :contributor, source_type: 'ExternalUser'
|
||||
has_many :internal_users, through: :user_exercise_interventions, source: :contributor, source_type: 'InternalUser'
|
||||
has_many :programming_groups, through: :user_exercise_interventions, source: :contributor, source_type: 'ProgrammingGroup'
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
def contributors
|
||||
@contributors ||= internal_users.distinct + external_users.distinct + programming_groups.distinct
|
||||
end
|
||||
|
||||
def self.create_default_interventions
|
||||
%w[BreakIntervention QuestionIntervention].each do |name|
|
||||
Intervention.find_or_create_by(name:)
|
||||
|
@ -18,7 +18,7 @@ class User < ApplicationRecord
|
||||
has_many :submissions, as: :contributor
|
||||
has_many :participations, through: :submissions, source: :exercise, as: :user
|
||||
has_many :user_proxy_exercise_exercises, as: :user
|
||||
has_many :user_exercise_interventions, as: :user
|
||||
has_many :user_exercise_interventions, as: :contributor
|
||||
has_many :testruns, as: :user
|
||||
has_many :interventions, through: :user_exercise_interventions
|
||||
has_many :remote_evaluation_mappings, as: :user
|
||||
|
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserExerciseIntervention < ApplicationRecord
|
||||
include Creation
|
||||
include ContributorCreation
|
||||
belongs_to :intervention
|
||||
belongs_to :exercise
|
||||
end
|
||||
|
Reference in New Issue
Block a user