Require pair programming for a given set of exercises
This commit is contained in:

committed by
Sebastian Serth

parent
934bb001bc
commit
26ea69eba8
@ -315,6 +315,8 @@ class ExercisesController < ApplicationController
|
|||||||
# we are just acting on behalf of a single user who has already worked on this exercise as part of a programming group **in the context of the current study group**
|
# we are just acting on behalf of a single user who has already worked on this exercise as part of a programming group **in the context of the current study group**
|
||||||
session[:pg_id] = pg.id
|
session[:pg_id] = pg.id
|
||||||
@current_contributor = pg
|
@current_contributor = pg
|
||||||
|
elsif session[:pg_id].blank? && PairProgramming23Study.participate_in_pp?(current_user, @exercise) && PairProgramming23Study::FORCED_EXERCISE_IDS.include?(@exercise.id)
|
||||||
|
return redirect_back(fallback_location: new_exercise_programming_group_path(@exercise))
|
||||||
elsif session[:pg_id].blank? && PairProgramming23Study.participate?(current_user, @exercise) && current_user.submissions.where(study_group_id: current_user.current_study_group_id, exercise: @exercise).none?
|
elsif session[:pg_id].blank? && PairProgramming23Study.participate?(current_user, @exercise) && current_user.submissions.where(study_group_id: current_user.current_study_group_id, exercise: @exercise).none?
|
||||||
Event.find_or_create_by(category: 'pp_work_alone', user: current_user, exercise: @exercise, data: nil, file_id: nil)
|
Event.find_or_create_by(category: 'pp_work_alone', user: current_user, exercise: @exercise, data: nil, file_id: nil)
|
||||||
current_user.pair_programming_waiting_users&.find_by(exercise: @exercise)&.update(status: :worked_alone)
|
current_user.pair_programming_waiting_users&.find_by(exercise: @exercise)&.update(status: :worked_alone)
|
||||||
|
@ -30,9 +30,10 @@ h1.d-inline-block = t('programming_groups.new.create_programming_pair')
|
|||||||
.col-12.d-none.d-md-block
|
.col-12.d-none.d-md-block
|
||||||
= render('form')
|
= render('form')
|
||||||
|
|
||||||
.row
|
- unless PairProgramming23Study.participate_in_pp?(current_user, @exercise) && PairProgramming23Study::FORCED_EXERCISE_IDS.include?(@exercise.id)
|
||||||
.col-12
|
.row
|
||||||
h5 = t('programming_groups.new.work_alone')
|
.col-12
|
||||||
== t('programming_groups.new.work_alone_description', path: implement_exercise_path(@exercise))
|
h5 = t('programming_groups.new.work_alone')
|
||||||
|
== t('programming_groups.new.work_alone_description', path: implement_exercise_path(@exercise))
|
||||||
|
|
||||||
= render('shared/modal', classes: 'modal-lg', id: 'modal-info-pair-programming', template: 'programming_groups/_info_pair_programming', title: t('programming_groups.new.pair_programming_info'))
|
= render('shared/modal', classes: 'modal-lg', id: 'modal-info-pair-programming', template: 'programming_groups/_info_pair_programming', title: t('programming_groups.new.pair_programming_info'))
|
||||||
|
@ -3,25 +3,27 @@
|
|||||||
class PairProgramming23Study
|
class PairProgramming23Study
|
||||||
ENABLE = ENV.fetch('PAIR_PROGRAMMING_23_STUDY', nil) == 'true'
|
ENABLE = ENV.fetch('PAIR_PROGRAMMING_23_STUDY', nil) == 'true'
|
||||||
STUDY_GROUP_IDS = [368, 451].freeze
|
STUDY_GROUP_IDS = [368, 451].freeze
|
||||||
|
# All easy tasks of the first week to be solved by the participants on their own
|
||||||
|
EXCLUDED_EXERCISE_IDS = [636, 647, 648, 649, 637, 638, 623, 639, 650, 625, 624, 651, 653, 654, 655, 664, 656].freeze
|
||||||
|
# The participants are forced to work in pairs on these tasks
|
||||||
|
FORCED_EXERCISE_IDS = [723].freeze
|
||||||
|
|
||||||
def self.participate?(user, exercise)
|
def self.participate?(user, exercise)
|
||||||
ENABLE || participate_in_pp?(user, exercise)
|
ENABLE || participate_in_pp?(user, exercise)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.participate_in_pp?(user, exercise)
|
def self.participate_in_pp?(user, exercise)
|
||||||
# All easy tasks of the first week to be solved by the participants on their own
|
return false unless experiment_course?(user.current_study_group_id)
|
||||||
if experiment_course?(user.current_study_group_id) && [636, 647, 648, 649, 637, 638, 623, 639, 650, 625, 624, 651, 653, 654, 655, 664, 656].exclude?(exercise.id)
|
return false if EXCLUDED_EXERCISE_IDS.include?(exercise.id)
|
||||||
return true if user.external_user? && fixed_enrolled_users.include?([user.consumer_id.to_s, user.external_id])
|
return true if user.external_user? && fixed_enrolled_users.include?([user.consumer_id.to_s, user.external_id])
|
||||||
|
|
||||||
user_group = user.id % 3 # => 0, 1, 2
|
user_group = user.id % 3 # => 0, 1, 2
|
||||||
case user_group
|
case user_group
|
||||||
when 0, 1
|
when 0, 1
|
||||||
return true
|
true
|
||||||
else # 2
|
else # 2
|
||||||
return false
|
false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.experiment_course?(study_group_id)
|
def self.experiment_course?(study_group_id)
|
||||||
|
Reference in New Issue
Block a user