Skip to content

Commit

Permalink
Remove PairProgramming23Study and instead use LTI parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kiragrammel committed Oct 13, 2023
1 parent dc14225 commit 9dd2ba2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 52 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/lti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def store_lti_session_data(parameters)
@lti_parameters.save!

session[:external_user_id] = current_user.id
session[:pair_programming] = params[:pair_programming] || false
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
retry
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ def implement # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedC
# 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)
elsif session[:pg_id].blank? && session[:pair_programming] == 'mandatory'
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? && session[:pair_programming] == 'optional' && 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)
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_through_lti
store_nonce(params[:oauth_nonce])
if params[:custom_redirect_target]
redirect_to(URI.parse(params[:custom_redirect_target].to_s).path)
elsif PairProgramming23Study.participate?(current_user, @exercise)
elsif params[:pair_programming]
redirect_to(new_exercise_programming_group_path(@exercise))
else
redirect_to(implement_exercise_path(@exercise),
Expand Down Expand Up @@ -98,7 +98,6 @@ def redirect_to_survey
# add a user pseudo ID if applicable
qp[:xi_pseudo_id] = Digest::SHA256.hexdigest(current_user.external_id)
qp[:co_study_group_id] = current_user.current_study_group_id
qp[:co_pair_programming23_study] = PairProgramming23Study.participate_in_pp?(current_user, @exercise).to_s
qp[:co_rfcs] = current_user.request_for_comments.includes(:submission).where(submission: {study_group_id: current_user.current_study_group_id}).size.to_s
qp[:co_comments] = current_user.comments.includes(:submission).where(submission: {study_group_id: current_user.current_study_group_id}).size.to_s
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/programming_groups/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ h1.d-inline-block = t('programming_groups.new.create_programming_pair')
#matching data-exercise-id[email protected]_s
.row
.col-12.mt-2.mb-4
- if PairProgramming23Study.participate_in_pp?(current_user, @exercise) && PairProgramming23Study::FORCED_EXERCISE_IDS.include?(@exercise.id)
- if session[:pair_programming] == 'mandatory'
p = t('programming_groups.new.info_forced_work_together', exercise_title: @exercise.title)
- else
p = t('programming_groups.new.info_work_together', exercise_title: @exercise.title)
Expand All @@ -32,7 +32,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)
- unless session[:pair_programming] == 'mandatory'
.row
.col-12
h5 = t('programming_groups.new.work_alone')
Expand Down
46 changes: 0 additions & 46 deletions lib/pair_programming23_study.rb

This file was deleted.

0 comments on commit 9dd2ba2

Please sign in to comment.