diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a41a5794..8eeeba8d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -28,8 +28,16 @@ class ExercisesController < ApplicationController 1 end - def java_course_token - "702cbd2a-c84c-4b37-923a-692d7d1532d0" + def experimental_courses + { + java17: "702cbd2a-c84c-4b37-923a-692d7d1532d0", + java1: "0ea88ea9-979a-44a3-b0e4-84ba58e5a05e" + } + end + + + def experimental_course?(course_token) + experimental_courses.has_value?(course_token) end def batch_update @@ -176,18 +184,30 @@ class ExercisesController < ApplicationController count_interventions_today = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count user_got_intervention_in_exercise = UserExerciseIntervention.where(user: current_user, exercise: @exercise).size >= max_intervention_count_per_exercise user_got_enough_interventions = count_interventions_today >= max_intervention_count_per_day or user_got_intervention_in_exercise - is_java_course = @course_token and @course_token.eql?(java_course_token) + @is_experimental_course = @course_token and experimental_course?(@course_token) - user_intervention_group = UserGroupSeparator.getInterventionGroup(current_user) + @experiment_group = UserGroupSeparator.getInterventionGroup(current_user) - case user_intervention_group - when :no_intervention - when :break_intervention - @show_break_interventions = (not user_solved_exercise and is_java_course and not user_got_enough_interventions) ? "true" : "false" - when :rfc_intervention - @show_rfc_interventions = (not user_solved_exercise and is_java_course and not user_got_enough_interventions) ? "true" : "false" + showInterventions = (@is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" + + case @experiment_group + when :rfc_intervention_stale_rfc + @show_rfc_interventions = showInterventions + when :break_intervention_stale_rfc + @show_break_interventions = showInterventions + when :no_intervention_stale_rfc + when :no_intervention_hide_rfc + @hide_rfc_button = "true" + when :break_intervention_show_rfc + @show_break_interventions = showInterventions + when :no_intervention_show_rfc + when :rfc_intervention_show_rfc + @show_rfc_interventions = showInterventions end + + + @search = Search.new @search.exercise = @exercise @submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first @@ -219,7 +239,7 @@ class ExercisesController < ApplicationController end else # no consumer, therefore implementation with internal user - @course_token = java_course_token + @course_token = "702cbd2a-c84c-4b37-923a-692d7d1532d0" end end private :set_course_token @@ -406,6 +426,11 @@ class ExercisesController < ApplicationController return end + if @is_experimental_course and (@rfc_group == :hide_rfc) + redirect_to_lti_return_path + return + end + rfc = @submission.own_unsolved_rfc if rfc # set a message that informs the user that his own RFC should be closed. diff --git a/app/models/submission.rb b/app/models/submission.rb index c27d01bd..ad0767a4 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -66,6 +66,10 @@ class Submission < ActiveRecord::Base end def unsolved_rfc - RequestForComment.unsolved.where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } + # old query + # RequestForComment.unsolved.where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } + + # experimental query: + RequestForComment.unsolved.joins('JOIN exercise_collections_exercises ece ON ece.exercise_id = request_for_comments.exercise_id').where('ece.exercise_collection_id != 3 OR user_id%10 > 3').where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } end end diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim index eb9f4d23..38e58588 100644 --- a/app/views/application/_session.html.slim +++ b/app/views/application/_session.html.slim @@ -8,9 +8,9 @@ - if current_user.internal_user? li = link_to(t('consumers.show.link'), current_user.consumer) if current_user.consumer li = link_to(t('internal_users.show.link'), current_user) - li = link_to(t('request_for_comments.index.all'), request_for_comments_path) + li = link_to(t('request_for_comments.index.all'), request_for_comments_path) + li = link_to(t('request_for_comments.index.get_my_rfc_activity'), my_rfc_activity_path) li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path) - li = link_to(t('request_for_comments.index.get_my_rfc_activity'), my_rfc_activity_path) - if current_user.internal_user? li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete) - else diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index e692b748..d5478907 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -3,6 +3,7 @@ - consumer_id = @current_user.respond_to?(:external_id) ? @current_user.consumer_id : '' #'tests' #(@current_user.uuid.present? ? @current_user.uuid : '') - show_break_interventions = @show_break_interventions || "false" - show_rfc_interventions = @show_rfc_interventions || "false" +- hide_rfc_button = @hide_rfc_button || false #editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path data-user-id=@current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-course_token=@course_token data-search-save-url=search_exercise_path(@exercise) div id="sidebar" class=(@exercise.hide_file_tree ? 'sidebar-col-collapsed' : 'sidebar-col') = render('editor_file_tree', exercise: @exercise, files: @files) div id='output_sidebar' class='output-col-collapsed' = render('exercises/editor_output', external_user_id: external_user_id, consumer_id: consumer_id ) @@ -14,7 +15,9 @@ = render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-stop', id: 'stop', label: t('exercises.editor.stop'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + r')) = render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-rocket', id: 'test', label: t('exercises.editor.test'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + t')) = render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-trophy', id: 'assess', label: t('exercises.editor.score'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + s')) - = render('editor_button', icon: 'fa fa-comment', id: 'requestComments', label: t('exercises.editor.requestComments'), title: t('exercises.editor.requestCommentsTooltip')) + // todo: check this + - if not hide_rfc_button + = render('editor_button', icon: 'fa fa-comment', id: 'requestComments', label: t('exercises.editor.requestComments'), title: t('exercises.editor.requestCommentsTooltip')) - @files.each do |file| = render('editor_frame', exercise: exercise, file: file) #autosave-label diff --git a/app/views/exercises/_editor_file_tree.html.slim b/app/views/exercises/_editor_file_tree.html.slim index 3f8334dc..c51dd855 100644 --- a/app/views/exercises/_editor_file_tree.html.slim +++ b/app/views/exercises/_editor_file_tree.html.slim @@ -26,7 +26,7 @@ div id='sidebar-uncollapsed' class=(@exercise.hide_file_tree ? 'hidden' : '') = render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', icon: 'fa fa-download', id: 'download', label: t('exercises.editor.download')) = render('editor_button', classes: 'btn-block btn-primary btn-sm', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => reload_exercise_path(@exercise)}, icon: 'fa fa-history', id: 'start-over', label: t('exercises.editor.start_over')) - - if !@course_token.blank? + //- if !@course_token.blank? .input-group.enforce-top-margin .enforce-right-margin = text_field_tag 'search-input-text', nil, placeholder: t('search.search_in_forum'), class: 'form-control' diff --git a/lib/user_group_separator.rb b/lib/user_group_separator.rb index 5be05ef6..4dcd00e1 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -3,12 +3,20 @@ class UserGroupSeparator # seperates user into 20% no intervention, 20% break intervention, 60% rfc intervention def self.getInterventionGroup(user) lastDigitId = user.id % 10 - if lastDigitId < 2 # 0,1 - :no_intervention - elsif lastDigitId < 4 # 2,3 - :break_intervention - else # 4,5,6,7,8,9 - :rfc_intervention + if lastDigitId < 1 # 0 + :rfc_intervention_stale_rfc + elsif lastDigitId < 2 # 1 + :break_intervention_stale_rfc + elsif lastDigitId < 3 # 2 + :no_intervention_stale_rfc + elsif lastDigitId < 4 # 3 + :no_intervention_hide_rfc + elsif lastDigitId < 5 # 4 + :break_intervention_show_rfc + elsif lastDigitId < 6 # 5 + :no_intervention_show_rfc + else # 6,7,8,9 + :rfc_intervention_show_rfc end end @@ -23,5 +31,4 @@ class UserGroupSeparator :recommended_assignment end end - end \ No newline at end of file