Add A/B/n test for interventions

This commit is contained in:
Sebastian Serth
2021-11-14 17:05:13 +01:00
parent 9079a0b15a
commit 9058ce00db
3 changed files with 84 additions and 2 deletions

33
lib/java21_study.rb Normal file
View File

@ -0,0 +1,33 @@
# frozen_string_literal: true
class Java21Study
def self.get_for(exercise)
java21_collection = ExerciseCollection.find_by(name: 'java2021', id: 13)
exercise.exercise_collections.include? java21_collection
end
def self.show_tips_intervention?(user, exercise)
java21_exercise = get_for(exercise)
return false unless java21_exercise # Exercise is not part of the experiment
user_group = UserGroupSeparator.get_intervention_group(user.id)
user_group == :show_tips_intervention
end
def self.show_break_intervention?(user, exercise)
java21_exercise = get_for(exercise)
return false unless java21_exercise # Exercise is not part of the experiment
user_group = UserGroupSeparator.get_intervention_group(user.id)
user_group == :show_break_intervention
end
def self.allow_redirect_to_community_solution?(user, exercise)
java21_exercise = get_for(exercise)
return false unless java21_exercise # Exercise is not part of the experiment
user_group = UserGroupSeparator.get_community_solution_group(user.id)
user_group == :show_community_solution
end
end