Merge pull request #105 from ThommyH/addBonusExerciseTesting

Add bonus exercise testing
This commit is contained in:
rteusner
2017-03-31 16:34:17 +02:00
committed by GitHub
2 changed files with 32 additions and 1 deletions

View File

@@ -36,8 +36,23 @@ class ProxyExercise < ActiveRecord::Base
Rails.logger.debug("retrieved assigned exercise for user #{user.id}: Exercise #{assigned_user_proxy_exercise.exercise}" )
assigned_user_proxy_exercise.exercise
else
Rails.logger.debug("find new matching exercise for user #{user.id}" )
matching_exercise =
if (token.eql? "47f4c736")
Rails.logger.debug("Proxy exercise with token 47f4c736, split user in groups..")
group = UserGroupSeparator.getGroupWeek2Testing(user)
Rails.logger.debug("user assigned to group #{group}")
case group
when :group_a
exercises.where(id: 348).first
when :group_b
exercises.where(id: 349).first
when :group_c
exercises.where(id: 350).first
when :group_d
exercises.where(id: 351).first
end
else
Rails.logger.debug("find new matching exercise for user #{user.id}" )
begin
find_matching_exercise(user)
rescue #fallback
@@ -46,8 +61,11 @@ class ProxyExercise < ActiveRecord::Base
@reason[:error] = "#{$!}"
exercises.shuffle.first
end
end
user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user, exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json)
matching_exercise
end
recommended_exercise
end