From ad29551bb41599c9c926b9ec4367e3c54a7ba1dd Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Thu, 30 Mar 2017 16:54:16 +0200 Subject: [PATCH 1/2] added code to test bonus exercise with different descriptions. --- app/models/proxy_exercise.rb | 19 ++++++++++++++++++- lib/user_group_separator.rb | 13 +++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/models/proxy_exercise.rb b/app/models/proxy_exercise.rb index f731aa61..67089bb7 100644 --- a/app/models/proxy_exercise.rb +++ b/app/models/proxy_exercise.rb @@ -36,8 +36,22 @@ 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") + group = UserGroupSeparator.getGroupWeek2Testing(user) + Rails.logger.debug("Bonus exercise 47f4c736 assigned user 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 +60,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 diff --git a/lib/user_group_separator.rb b/lib/user_group_separator.rb index 5be05ef6..c49ffe44 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -24,4 +24,17 @@ class UserGroupSeparator end end + def self.getGroupWeek2Testing(user) + groupById = user.id % 4 + if groupById == 0 + :group_a + elsif groupById == 1 + :group_b + elsif groupById == 2 + :group_c + else # 3 + :group_d + end + end + end \ No newline at end of file From 20c8a95a87406a20d8295b0f2b786d28e136786e Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Thu, 30 Mar 2017 16:56:55 +0200 Subject: [PATCH 2/2] quickfix --- app/models/proxy_exercise.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/proxy_exercise.rb b/app/models/proxy_exercise.rb index 67089bb7..84f5e487 100644 --- a/app/models/proxy_exercise.rb +++ b/app/models/proxy_exercise.rb @@ -38,8 +38,9 @@ class ProxyExercise < ActiveRecord::Base else 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("Bonus exercise 47f4c736 assigned user to group #{group}") + Rails.logger.debug("user assigned to group #{group}") case group when :group_a exercises.where(id: 348).first