<commit_before>require 'encoding'
require 'auto_complete'
require 'csv_invalid_line_error'

# Manages actions relating to editing and modifying
# groups.
class GroupsController < ApplicationController
  include GroupsHelper
  # Administrator
  before_filter      :authorize_only_for_admin

  auto_complete_for :student, :user_name
  auto_complete_for :assignment, :name

  def note_message
    @assignment = Assignment.find(params[:id])
    if params[:success]
      flash[:notice] = I18n.t('notes.create.success')
    else
      flash[:error] = I18n.t('notes.error')
    end
  end

  # Group administration functions -----------------------------------------
  # Verify that all functions below are included in the authorize filter above

  def new
    @assignment = Assignment.find(params[:assignment_id])
    begin
      new_grouping_data = @assignment.add_group(params[:new_group_name])
      head :ok
    rescue Exception => e
      render text: e.message, status: 400
    end
  end

  def remove_group
    # When a success div exists we can return successfully removed groups
    return unless request.delete?
    grouping = Grouping.find(params[:grouping_id])
    @assignment = grouping.assignment
    @errors = []
    @removed_groupings = []<commit_msg>add error message to new group with existing name<commit_after>require 'encoding'
require 'auto_complete'
require 'csv_invalid_line_error'

# Manages actions relating to editing and modifying
# groups.
class GroupsController < ApplicationController
  include GroupsHelper
  # Administrator
  before_filter      :authorize_only_for_admin

  auto_complete_for :student, :user_name
  auto_complete_for :assignment, :name

  def note_message
    @assignment = Assignment.find(params[:id])
    if params[:success]
      flash[:notice] = I18n.t('notes.create.success')
    else
      flash[:error] = I18n.t('notes.error')
    end
  end

  # Group administration functions -----------------------------------------
  # Verify that all functions below are included in the authorize filter above

  def new
    @assignment = Assignment.find(params[:assignment_id])
    begin
      new_grouping_data = @assignment.add_group(params[:new_group_name])
      head :ok
    rescue Exception => e
      flash[:error] = e.message
      render status: 400
    end
  end

  def remove_group
    # When a success div exists we can return successfully removed groups
    return unless request.delete?
    grouping = Grouping.find(params[:grouping_id])
    @assignment = grouping.assignment
    @errors = []
    @removed_groupings = []
{'fraction_non_alphanumeric': 0.10959968907889624, 'fraction_numerical': 0.005441119315973571, 'mean_word_length': 3.3043478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3851371', 'n_tokens_mistral': 739, 'n_tokens_neox': 712, 'n_words': 202}