Cleanup of Intervention and Bonus Exercise Experiments

This commit is contained in:
Ralf Teusner
2017-09-14 16:53:59 +02:00
parent 78f8dc4eb3
commit 9ce29d211b
6 changed files with 14 additions and 59 deletions

View File

@ -20,7 +20,7 @@ class ExercisesController < ApplicationController
end end
private :authorize! private :authorize!
def max_intervention_count def max_intervention_count_per_day
3 3
end end
@ -166,7 +166,7 @@ class ExercisesController < ApplicationController
def implement def implement
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
user_solved_exercise = @exercise.has_user_solved(current_user) user_solved_exercise = @exercise.has_user_solved(current_user)
user_got_enough_interventions = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count >= max_intervention_count user_got_enough_interventions = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count >= max_intervention_count_per_day
is_java_course = @course_token && @course_token.eql?(java_course_token) is_java_course = @course_token && @course_token.eql?(java_course_token)
user_intervention_group = UserGroupSeparator.getInterventionGroup(current_user) user_intervention_group = UserGroupSeparator.getInterventionGroup(current_user)
@ -203,7 +203,7 @@ class ExercisesController < ApplicationController
if match = lti_json.match(/^.*courses\/([a-z0-9\-]+)\/sections/) if match = lti_json.match(/^.*courses\/([a-z0-9\-]+)\/sections/)
match.captures.first match.captures.first
else else
java_course_token ""
end end
else else
"" ""

View File

@ -37,35 +37,17 @@ class ProxyExercise < ActiveRecord::Base
assigned_user_proxy_exercise.exercise assigned_user_proxy_exercise.exercise
else else
matching_exercise = 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}" ) Rails.logger.debug("find new matching exercise for user #{user.id}" )
begin begin
find_matching_exercise(user) find_matching_exercise(user)
rescue #fallback rescue => e #fallback
Rails.logger.error("finding matching exercise failed. Fall back to random exercise! Error: #{$!}" ) Rails.logger.error("finding matching exercise failed. Fall back to random exercise! Error: #{$!}" )
@reason[:reason] = "fallback because of error" @reason[:reason] = "fallback because of error"
@reason[:error] = "#{$!}" @reason[:error] = "#{$!}:\n\t#{e.backtrace.join("\n\t")}"
exercises.shuffle.first exercises.where("expected_difficulty > 1").shuffle.first # difficulty should be > 1 to prevent dummy exercise from being chosen.
end end
end
user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user, exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json) user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user, exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json)
matching_exercise matching_exercise
end end
recommended_exercise recommended_exercise
end end
@ -136,6 +118,7 @@ class ProxyExercise < ActiveRecord::Base
relative_knowledge_improvement[potex] += old_relative_loss_tag - new_relative_loss_tag relative_knowledge_improvement[potex] += old_relative_loss_tag - new_relative_loss_tag
end end
end end
highest_difficulty_user_has_accessed = exercises_user_has_accessed.map{|e| e.expected_difficulty}.sort.last || 0 highest_difficulty_user_has_accessed = exercises_user_has_accessed.map{|e| e.expected_difficulty}.sort.last || 0
best_matching_exercise = find_best_exercise(relative_knowledge_improvement, highest_difficulty_user_has_accessed) best_matching_exercise = find_best_exercise(relative_knowledge_improvement, highest_difficulty_user_has_accessed)
@reason[:reason] = "best matching exercise" @reason[:reason] = "best matching exercise"

View File

@ -8,7 +8,7 @@
- if current_user.admin? - if current_user.admin?
li = link_to(t('breadcrumbs.dashboard.show'), admin_dashboard_path) li = link_to(t('breadcrumbs.dashboard.show'), admin_dashboard_path)
li.divider li.divider
- models = [ExecutionEnvironment, Exercise, Consumer, CodeHarborLink, ExternalUser, FileType, FileTemplate, InternalUser].sort_by { |model| model.model_name.human(count: 2) } - models = [ExecutionEnvironment, Exercise, ProxyExercise, Tag, Consumer, CodeHarborLink, ExternalUser, FileType, FileTemplate, InternalUser].sort_by { |model| model.model_name.human(count: 2) }
- models.each do |model| - models.each do |model|
- if policy(model).index? - if policy(model).index?
li = link_to(model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path")) li = link_to(model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))

View File

@ -153,6 +153,9 @@ de:
submission: submission:
one: Abgabe one: Abgabe
other: Abgaben other: Abgaben
tag:
one: Tag
other: Tags
user_exercise_feedback: user_exercise_feedback:
one: Feedback one: Feedback
other: Feedback other: Feedback

View File

@ -1,24 +1,3 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en: en:
activerecord: activerecord:
attributes: attributes:
@ -174,6 +153,9 @@ en:
submission: submission:
one: Submission one: Submission
other: Submissions other: Submissions
tag:
one: Tag
other: Tags
user_exercise_feedback: user_exercise_feedback:
one: Feedback one: Feedback
other: Feedback other: Feedback

View File

@ -24,17 +24,4 @@ class UserGroupSeparator
end end
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 end