Assign users into A/B groups

This commit is contained in:
kiragrammel
2023-08-31 09:19:50 +02:00
committed by Sebastian Serth
parent 125215ea35
commit 0b42bba988
2 changed files with 22 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class SessionsController < ApplicationController
store_nonce(params[:oauth_nonce]) store_nonce(params[:oauth_nonce])
if params[:custom_redirect_target] if params[:custom_redirect_target]
redirect_to(URI.parse(params[:custom_redirect_target].to_s).path) redirect_to(URI.parse(params[:custom_redirect_target].to_s).path)
elsif PairProgramming23Study.participate? elsif PairProgramming23Study.participate?(current_user, @exercise)
redirect_to(new_exercise_programming_group_path(@exercise)) redirect_to(new_exercise_programming_group_path(@exercise))
else else
redirect_to(implement_exercise_path(@exercise), redirect_to(implement_exercise_path(@exercise),

View File

@ -2,9 +2,27 @@
class PairProgramming23Study class PairProgramming23Study
ENABLE = ENV.fetch('PAIR_PROGRAMMING_23_STUDY', nil) == 'true' ENABLE = ENV.fetch('PAIR_PROGRAMMING_23_STUDY', nil) == 'true'
STUDY_GROUP_IDS = [368, 451].freeze
def self.participate? def self.participate?(user, exercise)
# TODO: Decide which users are in the study ENABLE || participate_in_pp?(user, exercise)
ENABLE end
def self.participate_in_pp?(user, exercise)
# All easy tasks of the first week to be solved by the participants on their own
if experiment_course?(user.current_study_group_id) && [636, 647, 648, 649, 637, 638, 623, 639, 650, 625, 624, 651, 653, 654, 655, 664, 656].exclude?(exercise.id)
user_group = user.id % 3 # => 0, 1, 2
case user_group
when 0, 1
return true
else # 2
return false
end
end
false
end
def self.experiment_course?(study_group_id)
STUDY_GROUP_IDS.include? study_group_id
end end
end end