changed puts methods in proxy_exercise.rb to Rails.logger.debug. also changed Rails.logger.info to Rails.logger.debug
This commit is contained in:
@ -33,10 +33,10 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
assigned_user_proxy_exercise = user_proxy_exercise_exercises.where(user: user).first
|
assigned_user_proxy_exercise = user_proxy_exercise_exercises.where(user: user).first
|
||||||
recommended_exercise =
|
recommended_exercise =
|
||||||
if (assigned_user_proxy_exercise)
|
if (assigned_user_proxy_exercise)
|
||||||
Rails.logger.info("retrieved assigned exercise for user #{user.id}: Exercise #{assigned_user_proxy_exercise.exercise}" )
|
Rails.logger.debug("retrieved assigned exercise for user #{user.id}: Exercise #{assigned_user_proxy_exercise.exercise}" )
|
||||||
assigned_user_proxy_exercise.exercise
|
assigned_user_proxy_exercise.exercise
|
||||||
else
|
else
|
||||||
Rails.logger.info("find new matching exercise for user #{user.id}" )
|
Rails.logger.debug("find new matching exercise for user #{user.id}" )
|
||||||
matching_exercise =
|
matching_exercise =
|
||||||
begin
|
begin
|
||||||
find_matching_exercise(user)
|
find_matching_exercise(user)
|
||||||
@ -55,7 +55,7 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
def find_matching_exercise(user)
|
def find_matching_exercise(user)
|
||||||
exercises_user_has_accessed = user.submissions.where("cause IN ('submit','assess')").map{|s| s.exercise}.uniq
|
exercises_user_has_accessed = user.submissions.where("cause IN ('submit','assess')").map{|s| s.exercise}.uniq
|
||||||
tags_user_has_seen = exercises_user_has_accessed.map{|ex| ex.tags}.uniq.flatten
|
tags_user_has_seen = exercises_user_has_accessed.map{|ex| ex.tags}.uniq.flatten
|
||||||
Rails.logger.info("exercises_user_has_accessed #{exercises_user_has_accessed.map{|e|e.id}.join(",")}")
|
Rails.logger.debug("exercises_user_has_accessed #{exercises_user_has_accessed.map{|e|e.id}.join(",")}")
|
||||||
|
|
||||||
# find execises
|
# find execises
|
||||||
potential_recommended_exercises = []
|
potential_recommended_exercises = []
|
||||||
@ -65,10 +65,10 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
potential_recommended_exercises << ex
|
potential_recommended_exercises << ex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Rails.logger.info("potential_recommended_exercises: #{potential_recommended_exercises.map{|e|e.id}}")
|
Rails.logger.debug("potential_recommended_exercises: #{potential_recommended_exercises.map{|e|e.id}}")
|
||||||
# if all exercises contain tags which the user has never seen, recommend easiest exercise
|
# if all exercises contain tags which the user has never seen, recommend easiest exercise
|
||||||
if potential_recommended_exercises.empty?
|
if potential_recommended_exercises.empty?
|
||||||
Rails.logger.info("matched easiest exercise in pool")
|
Rails.logger.debug("matched easiest exercise in pool")
|
||||||
@reason[:reason] = "easiest exercise in pool. empty potential exercises"
|
@reason[:reason] = "easiest exercise in pool. empty potential exercises"
|
||||||
select_easiest_exercise(exercises)
|
select_easiest_exercise(exercises)
|
||||||
else
|
else
|
||||||
@ -80,8 +80,8 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
|
|
||||||
def select_best_matching_exercise(user, exercises_user_has_accessed, potential_recommended_exercises)
|
def select_best_matching_exercise(user, exercises_user_has_accessed, potential_recommended_exercises)
|
||||||
topic_knowledge_user_and_max = get_user_knowledge_and_max_knowledge(user, exercises_user_has_accessed)
|
topic_knowledge_user_and_max = get_user_knowledge_and_max_knowledge(user, exercises_user_has_accessed)
|
||||||
puts "topic_knowledge_user_and_max: #{topic_knowledge_user_and_max}"
|
Rails.logger.debug("topic_knowledge_user_and_max: #{topic_knowledge_user_and_max}")
|
||||||
puts "potential_recommended_exercises: #{potential_recommended_exercises.size}: #{potential_recommended_exercises.map{|p| p.id}}"
|
Rails.logger.debug("potential_recommended_exercises: #{potential_recommended_exercises.size}: #{potential_recommended_exercises.map{|p| p.id}}")
|
||||||
topic_knowledge_user = topic_knowledge_user_and_max[:user_topic_knowledge]
|
topic_knowledge_user = topic_knowledge_user_and_max[:user_topic_knowledge]
|
||||||
topic_knowledge_max = topic_knowledge_user_and_max[:max_topic_knowledge]
|
topic_knowledge_max = topic_knowledge_user_and_max[:max_topic_knowledge]
|
||||||
current_users_knowledge_lack = {}
|
current_users_knowledge_lack = {}
|
||||||
@ -93,13 +93,13 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
potential_recommended_exercises.each do |potex|
|
potential_recommended_exercises.each do |potex|
|
||||||
tags = potex.tags
|
tags = potex.tags
|
||||||
relative_knowledge_improvement[potex] = 0.0
|
relative_knowledge_improvement[potex] = 0.0
|
||||||
Rails.logger.info("review potential exercise #{potex.id}")
|
Rails.logger.debug("review potential exercise #{potex.id}")
|
||||||
tags.each do |tag|
|
tags.each do |tag|
|
||||||
tag_ratio = potex.exercise_tags.where(tag: tag).first.factor.to_f / potex.exercise_tags.inject(0){|sum, et| sum += et.factor }.to_f
|
tag_ratio = potex.exercise_tags.where(tag: tag).first.factor.to_f / potex.exercise_tags.inject(0){|sum, et| sum += et.factor }.to_f
|
||||||
max_topic_knowledge_ratio = potex.expected_difficulty * tag_ratio
|
max_topic_knowledge_ratio = potex.expected_difficulty * tag_ratio
|
||||||
old_relative_loss_tag = topic_knowledge_user[tag] / topic_knowledge_max[tag]
|
old_relative_loss_tag = topic_knowledge_user[tag] / topic_knowledge_max[tag]
|
||||||
new_relative_loss_tag = topic_knowledge_user[tag] / (topic_knowledge_max[tag] + max_topic_knowledge_ratio)
|
new_relative_loss_tag = topic_knowledge_user[tag] / (topic_knowledge_max[tag] + max_topic_knowledge_ratio)
|
||||||
puts "tag #{tag} old_relative_loss_tag #{old_relative_loss_tag}, new_relative_loss_tag #{new_relative_loss_tag}, tag_ratio #{tag_ratio}"
|
Rails.logger.debug("tag #{tag} old_relative_loss_tag #{old_relative_loss_tag}, new_relative_loss_tag #{new_relative_loss_tag}, tag_ratio #{tag_ratio}")
|
||||||
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
|
||||||
@ -110,27 +110,27 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
@reason[:current_users_knowledge_lack] = current_users_knowledge_lack
|
@reason[:current_users_knowledge_lack] = current_users_knowledge_lack
|
||||||
@reason[:relative_knowledge_improvement] = relative_knowledge_improvement
|
@reason[:relative_knowledge_improvement] = relative_knowledge_improvement
|
||||||
|
|
||||||
Rails.logger.info("current users knowledge loss: " + current_users_knowledge_lack.map{|k,v| "#{k} => #{v}"}.to_s)
|
Rails.logger.debug("current users knowledge loss: " + current_users_knowledge_lack.map{|k,v| "#{k} => #{v}"}.to_s)
|
||||||
Rails.logger.info("relative improvements #{relative_knowledge_improvement.map{|k,v| k.id.to_s + ':' + v.to_s}}")
|
Rails.logger.debug("relative improvements #{relative_knowledge_improvement.map{|k,v| k.id.to_s + ':' + v.to_s}}")
|
||||||
best_matching_exercise
|
best_matching_exercise
|
||||||
end
|
end
|
||||||
private :select_best_matching_exercise
|
private :select_best_matching_exercise
|
||||||
|
|
||||||
def find_best_exercise(relative_knowledge_improvement, highest_difficulty_user_has_accessed)
|
def find_best_exercise(relative_knowledge_improvement, highest_difficulty_user_has_accessed)
|
||||||
Rails.logger.info("select most appropiate exercise for user. his highest difficulty was #{highest_difficulty_user_has_accessed}")
|
Rails.logger.debug("select most appropiate exercise for user. his highest difficulty was #{highest_difficulty_user_has_accessed}")
|
||||||
sorted_exercises = relative_knowledge_improvement.sort_by{|k,v| v}.reverse
|
sorted_exercises = relative_knowledge_improvement.sort_by{|k,v| v}.reverse
|
||||||
|
|
||||||
sorted_exercises.each do |ex,diff|
|
sorted_exercises.each do |ex,diff|
|
||||||
Rails.logger.info("review exercise #{ex.id} diff: #{ex.expected_difficulty}")
|
Rails.logger.debug("review exercise #{ex.id} diff: #{ex.expected_difficulty}")
|
||||||
if (ex.expected_difficulty - highest_difficulty_user_has_accessed) <= 1
|
if (ex.expected_difficulty - highest_difficulty_user_has_accessed) <= 1
|
||||||
Rails.logger.info("matched exercise #{ex.id}")
|
Rails.logger.debug("matched exercise #{ex.id}")
|
||||||
return ex
|
return ex
|
||||||
else
|
else
|
||||||
Rails.logger.info("exercise #{ex.id} is too difficult")
|
Rails.logger.debug("exercise #{ex.id} is too difficult")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
easiest_exercise = sorted_exercises.min_by{|k,v| v}.first
|
easiest_exercise = sorted_exercises.min_by{|k,v| v}.first
|
||||||
Rails.logger.info("no match, select easiest exercise as fallback #{easiest_exercise.id}")
|
Rails.logger.debug("no match, select easiest exercise as fallback #{easiest_exercise.id}")
|
||||||
easiest_exercise
|
easiest_exercise
|
||||||
end
|
end
|
||||||
private :find_best_exercise
|
private :find_best_exercise
|
||||||
@ -189,17 +189,17 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
topic_knowledge_max = all_used_tags_with_count.keys.map{|t| [t, 0]}.to_h
|
topic_knowledge_max = all_used_tags_with_count.keys.map{|t| [t, 0]}.to_h
|
||||||
exercises_sorted = exercises.sort_by { |ex| ex.time_maximum_score(user)}
|
exercises_sorted = exercises.sort_by { |ex| ex.time_maximum_score(user)}
|
||||||
exercises_sorted.each do |ex|
|
exercises_sorted.each do |ex|
|
||||||
Rails.logger.info("exercise: #{ex.id}: #{ex}")
|
Rails.logger.debug("exercise: #{ex.id}: #{ex}")
|
||||||
user_score_factor = score(user, ex)
|
user_score_factor = score(user, ex)
|
||||||
ex.tags.each do |t|
|
ex.tags.each do |t|
|
||||||
tags_counter[t] += 1
|
tags_counter[t] += 1
|
||||||
tag_diminishing_return_factor = tag_diminishing_return_function(tags_counter[t], all_used_tags_with_count[t])
|
tag_diminishing_return_factor = tag_diminishing_return_function(tags_counter[t], all_used_tags_with_count[t])
|
||||||
tag_ratio = ex.exercise_tags.where(tag: t).first.factor.to_f / ex.exercise_tags.inject(0){|sum, et| sum += et.factor }.to_f
|
tag_ratio = ex.exercise_tags.where(tag: t).first.factor.to_f / ex.exercise_tags.inject(0){|sum, et| sum += et.factor }.to_f
|
||||||
Rails.logger.info("tag: #{t}, factor: #{ex.exercise_tags.where(tag: t).first.factor}, sumall: #{ex.exercise_tags.inject(0){|sum, et| sum += et.factor }}")
|
Rails.logger.debug("tag: #{t}, factor: #{ex.exercise_tags.where(tag: t).first.factor}, sumall: #{ex.exercise_tags.inject(0){|sum, et| sum += et.factor }}")
|
||||||
Rails.logger.info("tag #{t}, count #{tags_counter[t]}, max: #{all_used_tags_with_count[t]}, factor: #{tag_diminishing_return_factor}")
|
Rails.logger.debug("tag #{t}, count #{tags_counter[t]}, max: #{all_used_tags_with_count[t]}, factor: #{tag_diminishing_return_factor}")
|
||||||
Rails.logger.info("tag_ratio #{tag_ratio}")
|
Rails.logger.debug("tag_ratio #{tag_ratio}")
|
||||||
topic_knowledge_ratio = ex.expected_difficulty * tag_ratio
|
topic_knowledge_ratio = ex.expected_difficulty * tag_ratio
|
||||||
Rails.logger.info("topic_knowledge_ratio #{topic_knowledge_ratio}")
|
Rails.logger.debug("topic_knowledge_ratio #{topic_knowledge_ratio}")
|
||||||
topic_knowledge_loss_user[t] += (1 - user_score_factor) * topic_knowledge_ratio * tag_diminishing_return_factor
|
topic_knowledge_loss_user[t] += (1 - user_score_factor) * topic_knowledge_ratio * tag_diminishing_return_factor
|
||||||
topic_knowledge_max[t] += topic_knowledge_ratio * tag_diminishing_return_factor
|
topic_knowledge_max[t] += topic_knowledge_ratio * tag_diminishing_return_factor
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user