From 647e705a02811d4914145d044bd168161a3b5f6e Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 15 Feb 2018 17:26:36 +0100 Subject: [PATCH 01/16] don't redirect to rfc for experimental groups and hide the button for them --- app/controllers/exercises_controller.rb | 28 ++++++++++++++++++++----- app/views/exercises/_editor.html.slim | 4 +++- lib/user_group_separator.rb | 11 ++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 7d4d2c43..2c478df0 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -28,8 +28,13 @@ class ExercisesController < ApplicationController 1 end - def java_course_token - "702cbd2a-c84c-4b37-923a-692d7d1532d0" + experimental_courses = { + "java17" => "702cbd2a-c84c-4b37-923a-692d7d1532d0", + "java1" => "0ea88ea9-979a-44a3-b0e4-84ba58e5a05e" + } + + def experimental_course?(course_token) + experimental_courses.has_value?(course_token) end def batch_update @@ -176,16 +181,24 @@ 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) + @rfc_group = UserGroupSeparator.getRequestforCommentGroup(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" + @show_break_interventions = (is_experimental_course and not user_solved_exercise 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" + @show_rfc_interventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" + end + + case rfc_group + when :hide_rfc + @hide_rfc_button = "true" + when :stale_rfc + when :show_rfc end @search = Search.new @@ -396,6 +409,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/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index e692b748..672ce195 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,8 @@ = 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')) + - 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/lib/user_group_separator.rb b/lib/user_group_separator.rb index 5be05ef6..a0a45863 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -24,4 +24,15 @@ class UserGroupSeparator end end + def self.getRequestforCommentGroup(user) + lastDigitId = user.id % 10 + if lastDigitId < 2 # 0,1 + :hide_rfc + elsif lastDigitId < 4 # 2,3 + :stale_rfc + else # 4,5,6,7,8,9 + :show_rfc + end + end + end \ No newline at end of file From 208a856cb886602e7b8e1d5101987e19bc364c6b Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 15 Feb 2018 17:27:02 +0100 Subject: [PATCH 02/16] hide links to rfc overviews from external users --- app/views/application/_session.html.slim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim index eb9f4d23..e529c957 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.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) + li = link_to(t('request_for_comments.index.all'), request_for_comments_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 From 4778fc68fc8d0967da4948153c1f9ded6227d553 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 15 Feb 2018 17:27:35 +0100 Subject: [PATCH 03/16] don't present rfcs of experimental users to others --- app/models/request_for_comment.rb | 1 + app/models/submission.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index d0c300b6..e46f3048 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -8,6 +8,7 @@ class RequestForComment < ActiveRecord::Base has_many :subscriptions scope :unsolved, -> { where(solved: [false, nil]) } + scope :not_stale, -> { where("user_id%10 <2 OR user_id%10 >= 4").where(exercise.exercise_collections.none{|ec| ec.id = 3} } ########### todo def self.last_per_user(n = 5) from("(#{row_number_user_sql}) as request_for_comments").where("row_number <= ?", n) diff --git a/app/models/submission.rb b/app/models/submission.rb index c27d01bd..496ae056 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -66,6 +66,6 @@ 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) } + RequestForComment.unsolved.not_stale.where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } end end From fbff875348754ed4fbde1d47f9bdd4096fb08980 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Tue, 27 Feb 2018 13:38:31 +0100 Subject: [PATCH 04/16] remove rfc button altogether first, put in correct experiment groups --- app/assets/stylesheets/editor.css.scss | 6 ++++- app/controllers/exercises_controller.rb | 32 +++++++++++++------------ app/views/exercises/_editor.html.slim | 4 ++-- lib/user_group_separator.rb | 20 +++++++++++----- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/assets/stylesheets/editor.css.scss b/app/assets/stylesheets/editor.css.scss index 755e3409..c22ba185 100644 --- a/app/assets/stylesheets/editor.css.scss +++ b/app/assets/stylesheets/editor.css.scss @@ -47,8 +47,12 @@ button i.fa-spin { font-size: 80%; } + .button-two-only, .btn-group-two-only { + width: 50%; + } + button, .btn-group { - width: 33.33333%; + width: 50%; } .btn-group { diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2c478df0..ef1af57e 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -28,10 +28,13 @@ class ExercisesController < ApplicationController 1 end - experimental_courses = { - "java17" => "702cbd2a-c84c-4b37-923a-692d7d1532d0", - "java1" => "0ea88ea9-979a-44a3-b0e4-84ba58e5a05e" - } + 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) @@ -183,23 +186,22 @@ class ExercisesController < ApplicationController user_got_enough_interventions = count_interventions_today >= max_intervention_count_per_day or user_got_intervention_in_exercise @is_experimental_course = @course_token and experimental_course?(@course_token) - user_intervention_group = UserGroupSeparator.getInterventionGroup(current_user) - @rfc_group = UserGroupSeparator.getRequestforCommentGroup(current_user) + @experiment_group = UserGroupSeparator.getInterventionGroup(current_user) - case user_intervention_group - when :no_intervention + + case @experiment_group + # todo + when :no_intervention_hide_rfc + @hide_rfc_button = "true" + when :no_intervention_stale_rfc when :break_intervention @show_break_interventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" when :rfc_intervention @show_rfc_interventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" end - case rfc_group - when :hide_rfc - @hide_rfc_button = "true" - when :stale_rfc - when :show_rfc - end + + @search = Search.new @search.exercise = @exercise @@ -232,7 +234,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 diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index 672ce195..28668a89 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -15,8 +15,8 @@ = 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')) - - if not hide_rfc_button - = render('editor_button', icon: 'fa fa-comment', id: 'requestComments', label: t('exercises.editor.requestComments'), title: t('exercises.editor.requestCommentsTooltip')) + //- 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/lib/user_group_separator.rb b/lib/user_group_separator.rb index a0a45863..8e1771c1 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 From 3df8af8c606431584772808a42f93aecc0d165ee Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 28 Mar 2018 14:29:49 +0200 Subject: [PATCH 05/16] removed superflous method fixed scope --- app/models/request_for_comment.rb | 2 +- lib/user_group_separator.rb | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index 2d91cc8f..c82d2d15 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -8,7 +8,7 @@ class RequestForComment < ActiveRecord::Base has_many :subscriptions scope :unsolved, -> { where(solved: [false, nil]) } - scope :not_stale, -> { where("user_id%10 <2 OR user_id%10 >= 4").where(exercise.exercise_collections.none{|ec| ec.id = 3} } ########### todo + scope :not_stale, -> { where("user_id%10 < 3").where(exercise.exercise_collections.none{|ec| ec.id = 3} } def self.last_per_user(n = 5) from("(#{row_number_user_sql}) as request_for_comments") diff --git a/lib/user_group_separator.rb b/lib/user_group_separator.rb index 8e1771c1..4dcd00e1 100644 --- a/lib/user_group_separator.rb +++ b/lib/user_group_separator.rb @@ -31,16 +31,4 @@ class UserGroupSeparator :recommended_assignment end end - - def self.getRequestforCommentGroup(user) - lastDigitId = user.id % 10 - if lastDigitId < 2 # 0,1 - :hide_rfc - elsif lastDigitId < 4 # 2,3 - :stale_rfc - else # 4,5,6,7,8,9 - :show_rfc - end - end - end \ No newline at end of file From b314bab1e19f8b4c50a1128674139f127e25336b Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 28 Mar 2018 14:55:25 +0200 Subject: [PATCH 06/16] complete experiment groups, add view code --- app/controllers/exercises_controller.rb | 17 +++++++++++------ app/views/exercises/_editor.html.slim | 5 +++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index ef1af57e..9d44b02e 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -188,16 +188,21 @@ class ExercisesController < ApplicationController @experiment_group = UserGroupSeparator.getInterventionGroup(current_user) + showInterventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" case @experiment_group - # todo + 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 :no_intervention_stale_rfc - when :break_intervention - @show_break_interventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" - when :rfc_intervention - @show_rfc_interventions = (is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false" + when :break_intervention_show_rfc + @show_break_interventions = showInterventions + when :no_intervention_show_rfc + when :rfc_intervention_show_rfc + @show_rfc_interventions = showInterventions end diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index 28668a89..591d5b75 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -15,8 +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')) - //- if not hide_rfc_button - // = 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 From ecd1f31eed8ed515e5c645c7287b2cd8538c08ba Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 28 Mar 2018 15:08:34 +0200 Subject: [PATCH 07/16] added missing closing bracket --- app/models/request_for_comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index c82d2d15..f0f2953f 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -8,7 +8,7 @@ class RequestForComment < ActiveRecord::Base has_many :subscriptions scope :unsolved, -> { where(solved: [false, nil]) } - scope :not_stale, -> { where("user_id%10 < 3").where(exercise.exercise_collections.none{|ec| ec.id = 3} } + scope :not_stale, -> { where("user_id%10 < 3").where(exercise.exercise_collections.none{|ec| ec.id = 3}) } def self.last_per_user(n = 5) from("(#{row_number_user_sql}) as request_for_comments") From faeb0e139a72ba2f369e2b4ee25291a30b42129f Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 28 Mar 2018 15:22:55 +0200 Subject: [PATCH 08/16] fixed variable name --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 9d44b02e..467e71cc 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -188,7 +188,7 @@ class ExercisesController < ApplicationController @experiment_group = UserGroupSeparator.getInterventionGroup(current_user) - showInterventions = (is_experimental_course and not user_solved_exercise 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 From 3c9b1c6f715772b8418a72ae3a7e4d48e96bcc84 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Mon, 16 Apr 2018 14:24:26 +0200 Subject: [PATCH 09/16] change string to boolean, since this is evaluated in the slim template and not in javascript --- app/views/exercises/_editor.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index 591d5b75..d5478907 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -3,7 +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" +- 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 ) From 4739632db2c47f9ca32a091a6a50aeca72e7a671 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 15:29:56 +0200 Subject: [PATCH 10/16] remove search bar --- app/views/exercises/_editor_file_tree.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' From f1830f5322cf43747551295dd810d608257467c8 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 15:30:18 +0200 Subject: [PATCH 11/16] re-introduce my_request_for_comments option for external_users --- app/views/application/_session.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim index e529c957..38e58588 100644 --- a/app/views/application/_session.html.slim +++ b/app/views/application/_session.html.slim @@ -9,8 +9,8 @@ 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.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) + li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path) - if current_user.internal_user? li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete) - else From f7392b1c05d70e36e5fb93624560c9ae3f3e1521 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 16:04:50 +0200 Subject: [PATCH 12/16] altered stale rfc query --- app/models/request_for_comment.rb | 3 ++- app/models/submission.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index f0f2953f..fc77352c 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -8,7 +8,8 @@ class RequestForComment < ActiveRecord::Base has_many :subscriptions scope :unsolved, -> { where(solved: [false, nil]) } - scope :not_stale, -> { where("user_id%10 < 3").where(exercise.exercise_collections.none{|ec| ec.id = 3}) } + scope :stale, -> { where(exercise.exercise_collections.any{|ec| ec.id = 3}).where("user_id%10 < 3")} + scope :not, ->(scope) { where(scope.where_values.reduce(:and).not) } def self.last_per_user(n = 5) from("(#{row_number_user_sql}) as request_for_comments") diff --git a/app/models/submission.rb b/app/models/submission.rb index 496ae056..74ffcd24 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -66,6 +66,6 @@ class Submission < ActiveRecord::Base end def unsolved_rfc - RequestForComment.unsolved.not_stale.where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } + RequestForComment.unsolved.not(:stale).where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } end end From e9462409fd05fe796ba7485a9498ed382c5f775a Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 17:06:04 +0200 Subject: [PATCH 13/16] fixed the query, removed scopes, added paranthesis for clarity. --- app/controllers/exercises_controller.rb | 2 +- app/models/request_for_comment.rb | 2 -- app/models/submission.rb | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 467e71cc..ea72dfde 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -416,7 +416,7 @@ class ExercisesController < ApplicationController return end - if @is_experimental_course and @rfc_group == :hide_rfc + if @is_experimental_course and (@rfc_group == :hide_rfc) redirect_to_lti_return_path return end diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index fc77352c..d00d08eb 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -8,8 +8,6 @@ class RequestForComment < ActiveRecord::Base has_many :subscriptions scope :unsolved, -> { where(solved: [false, nil]) } - scope :stale, -> { where(exercise.exercise_collections.any{|ec| ec.id = 3}).where("user_id%10 < 3")} - scope :not, ->(scope) { where(scope.where_values.reduce(:and).not) } def self.last_per_user(n = 5) from("(#{row_number_user_sql}) as request_for_comments") diff --git a/app/models/submission.rb b/app/models/submission.rb index 74ffcd24..5f86d0b8 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.not(:stale).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.not(:stale).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.not(question: nil).order("RANDOM()").to_a end end From b651b1b179fb41874acf69c968939730d2b15bc8 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 17:13:20 +0200 Subject: [PATCH 14/16] fixed the experimental query --- app/models/submission.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 5f86d0b8..c9fafb97 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -70,6 +70,6 @@ class Submission < ActiveRecord::Base # RequestForComment.unsolved.not(:stale).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.not(question: nil).order("RANDOM()").to_a + 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.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } end end From 633bfa6cc58d9cafc6277126d79d2be5429f0659 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 17:20:17 +0200 Subject: [PATCH 15/16] ... hopefully I got the query correct this time... --- app/models/submission.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index c9fafb97..ad0767a4 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -67,9 +67,9 @@ class Submission < ActiveRecord::Base def unsolved_rfc # old query - # RequestForComment.unsolved.not(:stale).where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_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) } # 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.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) } + 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 From 20724b56b06f7088106e425dd81b0577920c41b5 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 May 2018 18:00:36 +0200 Subject: [PATCH 16/16] removed deploy script as capistrano call seems to be working now.. --- config/deploy.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 1fac842e..0f849a06 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -22,12 +22,4 @@ namespace :deploy do end end end -end - -namespace :whenever do - task :update_crontab do - run 'bundle exec whenever --update-crontab' - end -end - -after 'deploy', 'whenever:update_crontab' +end \ No newline at end of file