Add events for pair programming study
This commit is contained in:

committed by
Sebastian Serth

parent
d1d5b0df6f
commit
79422225a8
@@ -1,10 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EventsController < ApplicationController
|
||||
def authorize!
|
||||
authorize(@event || @events)
|
||||
end
|
||||
private :authorize!
|
||||
before_action :require_user!
|
||||
|
||||
def create
|
||||
@event = Event.new(event_params)
|
||||
@@ -20,12 +17,21 @@ class EventsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authorize!
|
||||
authorize(@event || @events)
|
||||
end
|
||||
|
||||
def event_params
|
||||
# The file ID processed here is the context of the exercise (template),
|
||||
# not in the context of the submission!
|
||||
params[:event]
|
||||
&.permit(:category, :data, :exercise_id, :file_id)
|
||||
&.merge(user: current_user)
|
||||
&.merge(user: current_user, programming_group:, study_group_id: current_user.current_study_group_id)
|
||||
end
|
||||
|
||||
def programming_group
|
||||
current_contributor if current_contributor.programming_group?
|
||||
end
|
||||
private :event_params
|
||||
end
|
||||
|
@@ -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 PairProgramming23Study.participate?(current_user, @exercise) && current_user.submissions.where(study_group_id: current_user.current_study_group_id, exercise: @exercise).any?
|
||||
Event.create(category: 'pp_work_alone', user: current_user, exercise: @exercise, data: nil, file_id: nil)
|
||||
end
|
||||
|
||||
user_solved_exercise = @exercise.solved_by?(current_contributor)
|
||||
|
@@ -7,6 +7,7 @@ class ProgrammingGroupsController < ApplicationController
|
||||
before_action :set_exercise_and_authorize
|
||||
|
||||
def new
|
||||
Event.create(category: 'page_visit', user: current_user, exercise: @exercise, data: 'programming_groups_new', file_id: nil)
|
||||
if current_user.submissions.where(exercise: @exercise, study_group_id: current_user.current_study_group_id).any?
|
||||
# A learner has worked on this exercise **alone** in the context of the **current study group**, so we redirect them to their progress.
|
||||
redirect_to_exercise
|
||||
@@ -36,6 +37,10 @@ class ProgrammingGroupsController < ApplicationController
|
||||
@programming_group.add(current_user)
|
||||
end
|
||||
|
||||
unless @programming_group.valid?
|
||||
Event.create(category: 'pp_invalid_partners', user: current_user, exercise: @exercise, data: programming_group_params[:programming_partner_ids], file_id: nil)
|
||||
end
|
||||
|
||||
create_and_respond(object: @programming_group, path: proc { implement_exercise_path(@exercise) }) do
|
||||
session[:pg_id] = @programming_group.id
|
||||
nil
|
||||
|
Reference in New Issue
Block a user