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**
|
||||
session[:pg_id] = pg.id
|
||||
@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?
|
||||
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)
|
||||
|
@ -30,6 +30,7 @@ h1.d-inline-block = t('programming_groups.new.create_programming_pair')
|
||||
.col-12.d-none.d-md-block
|
||||
= render('form')
|
||||
|
||||
- unless PairProgramming23Study.participate_in_pp?(current_user, @exercise) && PairProgramming23Study::FORCED_EXERCISE_IDS.include?(@exercise.id)
|
||||
.row
|
||||
.col-12
|
||||
h5 = t('programming_groups.new.work_alone')
|
||||
|
@ -3,26 +3,28 @@
|
||||
class PairProgramming23Study
|
||||
ENABLE = ENV.fetch('PAIR_PROGRAMMING_23_STUDY', nil) == 'true'
|
||||
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)
|
||||
ENABLE || participate_in_pp?(user, exercise)
|
||||
end
|
||||
|
||||
def self.participate_in_pp?(user, exercise)
|
||||
# All easy tasks of the first week to be solved by the participants on their own
|
||||
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 unless experiment_course?(user.current_study_group_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])
|
||||
|
||||
user_group = user.id % 3 # => 0, 1, 2
|
||||
case user_group
|
||||
when 0, 1
|
||||
return true
|
||||
true
|
||||
else # 2
|
||||
return false
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def self.experiment_course?(study_group_id)
|
||||
STUDY_GROUP_IDS.include? study_group_id
|
||||
|
Reference in New Issue
Block a user