diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 337cb9d4..03e08da2 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -20,7 +20,7 @@ class ExercisesController < ApplicationController end private :authorize! - def max_intervention_count + def max_intervention_count_per_day 3 end @@ -166,7 +166,7 @@ class ExercisesController < ApplicationController def implement redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? 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) user_intervention_group = UserGroupSeparator.getInterventionGroup(current_user) @@ -203,7 +203,7 @@ class ExercisesController < ApplicationController if match = lti_json.match(/^.*courses\/([a-z0-9\-]+)\/sections/) match.captures.first else - java_course_token + "" end else "" diff --git a/app/models/proxy_exercise.rb b/app/models/proxy_exercise.rb index 30cd7813..5922e062 100644 --- a/app/models/proxy_exercise.rb +++ b/app/models/proxy_exercise.rb @@ -37,35 +37,17 @@ class ProxyExercise < ActiveRecord::Base assigned_user_proxy_exercise.exercise 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("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 + rescue => e #fallback Rails.logger.error("finding matching exercise failed. Fall back to random exercise! Error: #{$!}" ) @reason[:reason] = "fallback because of error" - @reason[:error] = "#{$!}" - exercises.shuffle.first + @reason[:error] = "#{$!}:\n\t#{e.backtrace.join("\n\t")}" + exercises.where("expected_difficulty > 1").shuffle.first # difficulty should be > 1 to prevent dummy exercise from being chosen. 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 @@ -136,6 +118,7 @@ class ProxyExercise < ActiveRecord::Base relative_knowledge_improvement[potex] += old_relative_loss_tag - new_relative_loss_tag end end + 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) @reason[:reason] = "best matching exercise" diff --git a/app/views/application/_navigation.html.slim b/app/views/application/_navigation.html.slim index b9663d3f..fbeca1c3 100644 --- a/app/views/application/_navigation.html.slim +++ b/app/views/application/_navigation.html.slim @@ -8,7 +8,7 @@ - if current_user.admin? li = link_to(t('breadcrumbs.dashboard.show'), admin_dashboard_path) 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| - if policy(model).index? li = link_to(model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path")) diff --git a/config/locales/de.yml b/config/locales/de.yml index a8681878..a98c76dd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -153,6 +153,9 @@ de: submission: one: Abgabe other: Abgaben + tag: + one: Tag + other: Tags user_exercise_feedback: one: Feedback other: Feedback diff --git a/config/locales/en.yml b/config/locales/en.yml index f53f6485..ecd65312 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: activerecord: attributes: @@ -174,6 +153,9 @@ en: submission: one: Submission other: Submissions + tag: + one: Tag + other: Tags user_exercise_feedback: one: Feedback other: Feedback diff --git a/lib/user_group_separator.rb b/lib/user_group_separator.rb index c49ffe44..5be05ef6 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -24,17 +24,4 @@ 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