<commit_before>class ParticipantsController < ApplicationController
  load_and_authorize_resource :suite
  load_and_authorize_resource :participant, through: :suite, shallow: true, except: :create
  before_filter :authorize_suite!

  def new
    @participant.suite = @suite
  end

  def create
    @suite = Suite.find(params[:participant][:suite_id])

    authorize! :update, @suite

    participant_data = process_participant_autocomplete_params(params[:participant])

    participant_data.each do |data|
      @suite.participants.create(data) unless @suite.participants.exists?(student_id: data[:student_id])
    end

    flash[:success] = t(:"participants.create.success")
    redirect_to @suite<commit_msg>Add groups' users to the suite when adding participants from a group.<commit_after>class ParticipantsController < ApplicationController
  load_and_authorize_resource :suite
  load_and_authorize_resource :participant, through: :suite, shallow: true, except: :create
  before_filter :authorize_suite!

  def new
    @participant.suite = @suite
  end

  def create
    @suite = Suite.find(params[:participant][:suite_id])

    authorize! :update, @suite

    participant_data = process_participant_autocomplete_params(params[:participant])

    group_ids = []

    participant_data.each do |data|
      @suite.participants.create(data) unless @suite.participants.exists?(student_id: data[:student_id])
      group_ids << data[:group_id] if data[:group_id]
    end

    unless group_ids.blank?
      users = Group.find(group_ids).collect(&:users).flatten
      users.each { |u| u.add_role :suite_manager, @suite }
    end

    flash[:success] = t(:"participants.create.success")
    redirect_to @suite
{'fraction_non_alphanumeric': 0.10310486233157587, 'fraction_numerical': 0.0, 'mean_word_length': 4.8493150684931505, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2355000', 'n_tokens_mistral': 534, 'n_tokens_neox': 505, 'n_words': 107}