Merge pull request #174 from openHPI/disable_rfcs

Disable rfcs
This commit is contained in:
rteusner
2018-05-25 10:35:13 +02:00
committed by GitHub
6 changed files with 62 additions and 23 deletions

View File

@ -28,8 +28,16 @@ class ExercisesController < ApplicationController
1 1
end end
def java_course_token def experimental_courses
"702cbd2a-c84c-4b37-923a-692d7d1532d0" {
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 end
def batch_update 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 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_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 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 showInterventions = (@is_experimental_course and not user_solved_exercise and not user_got_enough_interventions) ? "true" : "false"
when :no_intervention
when :break_intervention case @experiment_group
@show_break_interventions = (not user_solved_exercise and is_java_course and not user_got_enough_interventions) ? "true" : "false" when :rfc_intervention_stale_rfc
when :rfc_intervention @show_rfc_interventions = showInterventions
@show_rfc_interventions = (not user_solved_exercise and is_java_course and not user_got_enough_interventions) ? "true" : "false" 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 end
@search = Search.new @search = Search.new
@search.exercise = @exercise @search.exercise = @exercise
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first @submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
@ -219,7 +239,7 @@ class ExercisesController < ApplicationController
end end
else else
# no consumer, therefore implementation with internal user # no consumer, therefore implementation with internal user
@course_token = java_course_token @course_token = "702cbd2a-c84c-4b37-923a-692d7d1532d0"
end end
end end
private :set_course_token private :set_course_token
@ -406,6 +426,11 @@ class ExercisesController < ApplicationController
return return
end end
if @is_experimental_course and (@rfc_group == :hide_rfc)
redirect_to_lti_return_path
return
end
rfc = @submission.own_unsolved_rfc rfc = @submission.own_unsolved_rfc
if rfc if rfc
# set a message that informs the user that his own RFC should be closed. # set a message that informs the user that his own RFC should be closed.

View File

@ -66,6 +66,10 @@ class Submission < ActiveRecord::Base
end end
def unsolved_rfc 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
end end

View File

@ -9,8 +9,8 @@
li = link_to(t('consumers.show.link'), current_user.consumer) if current_user.consumer 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('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_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_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? - if current_user.internal_user?
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete) li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
- else - else

View File

@ -3,6 +3,7 @@
- consumer_id = @current_user.respond_to?(:external_id) ? @current_user.consumer_id : '' #'tests' #(@current_user.uuid.present? ? @current_user.uuid : '') - 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_break_interventions = @show_break_interventions || "false"
- show_rfc_interventions = @show_rfc_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) #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="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 ) div id='output_sidebar' class='output-col-collapsed' = render('exercises/editor_output', external_user_id: external_user_id, consumer_id: consumer_id )
@ -14,6 +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-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-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', 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'))
// 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')) = render('editor_button', icon: 'fa fa-comment', id: 'requestComments', label: t('exercises.editor.requestComments'), title: t('exercises.editor.requestCommentsTooltip'))
- @files.each do |file| - @files.each do |file|
= render('editor_frame', exercise: exercise, file: file) = render('editor_frame', exercise: exercise, file: file)

View File

@ -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 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')) = 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 .input-group.enforce-top-margin
.enforce-right-margin .enforce-right-margin
= text_field_tag 'search-input-text', nil, placeholder: t('search.search_in_forum'), class: 'form-control' = text_field_tag 'search-input-text', nil, placeholder: t('search.search_in_forum'), class: 'form-control'

View File

@ -3,12 +3,20 @@ class UserGroupSeparator
# seperates user into 20% no intervention, 20% break intervention, 60% rfc intervention # seperates user into 20% no intervention, 20% break intervention, 60% rfc intervention
def self.getInterventionGroup(user) def self.getInterventionGroup(user)
lastDigitId = user.id % 10 lastDigitId = user.id % 10
if lastDigitId < 2 # 0,1 if lastDigitId < 1 # 0
:no_intervention :rfc_intervention_stale_rfc
elsif lastDigitId < 4 # 2,3 elsif lastDigitId < 2 # 1
:break_intervention :break_intervention_stale_rfc
else # 4,5,6,7,8,9 elsif lastDigitId < 3 # 2
:rfc_intervention :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
end end
@ -23,5 +31,4 @@ class UserGroupSeparator
:recommended_assignment :recommended_assignment
end end
end end
end end