<commit_before>class ExperimentsController < ApplicationController
  include PermissionHelper
  before_action :set_experiment, except: [:new, :create]
  before_action :set_project, only: [:new, :create]

  # except parameter could be used but it is not working.
  layout :choose_layout

  def new
    @experiment = Experiment.new
    respond_to do |format|
      format.json  {
        render json:{
          html: render_to_string( {
            partial: "new_modal.html.erb"
          })
        }
      }
    end
  end

  def create
    @experiment = Experiment.new(experiment_params)
    @experiment.created_by = current_user
    @experiment.last_modified_by = current_user
    @experiment.project = @project
    if @experiment.save
      @project.experiments << @experiment
      flash[:success] = t('experiments.create.success_flash', name: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger]  = t('experiments.create.error_flash')
      render :new
    end
  end

  def canvas
    @project = @experiment.project
  end

  def update
    @experiment.update_attributes(experiment_params)
    @experiment.last_modified_by = current_user
    if @experiment.save
      flash[:success] = t('experiments.update.success_flash', name: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger] = t('experiments.update.error_flash')
      render :edit
    end
  end

  def archive_experiment
    @experiment.archived = true
    @experiment.archived_by = current_user
    @experiment.archived_on = DateTime.now
    if @experiment.save
      flash[:success] = t('experiments.archive.success_flash', name: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger] = t('experiments.archive.error_flash')
    end
  end

  private

  def set_experiment
    @experiment = Experiment.find_by_id(params[:id])
  end

  def set_project
    @project = Project.find_by_id(params[:project_id])
  end

  def experiment_params
    params.require(:experiment).permit(:name, :description)
  end
<commit_msg>fixed translation sting 'name' to 'experiment'<commit_after>class ExperimentsController < ApplicationController
  include PermissionHelper
  before_action :set_experiment, except: [:new, :create]
  before_action :set_project, only: [:new, :create]

  # except parameter could be used but it is not working.
  layout :choose_layout

  def new
    @experiment = Experiment.new
    respond_to do |format|
      format.json  {
        render json:{
          html: render_to_string( {
            partial: "new_modal.html.erb"
          })
        }
      }
    end
  end

  def create
    @experiment = Experiment.new(experiment_params)
    @experiment.created_by = current_user
    @experiment.last_modified_by = current_user
    @experiment.project = @project
    if @experiment.save
      @project.experiments << @experiment
      flash[:success] = t('experiments.create.success_flash', experiment: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger]  = t('experiments.create.error_flash')
      render :new
    end
  end

  def canvas
    @project = @experiment.project
  end

  def update
    @experiment.update_attributes(experiment_params)
    @experiment.last_modified_by = current_user
    if @experiment.save
      flash[:success] = t('experiments.update.success_flash', experiment: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger] = t('experiments.update.error_flash')
      render :edit
    end
  end

  def archive_experiment
    @experiment.archived = true
    @experiment.archived_by = current_user
    @experiment.archived_on = DateTime.now
    if @experiment.save
      flash[:success] = t('experiments.archive.success_flash', experiment: @experiment.name)
      # have to change to experiments path
      redirect_to root_path
    else
      flash[:danger] = t('experiments.archive.error_flash')
    end
  end

  private

  def set_experiment
    @experiment = Experiment.find_by_id(params[:id])
  end

  def set_project
    @project = Project.find_by_id(params[:project_id])
  end

  def experiment_params
    params.require(:experiment).permit(:name, :description)
  end

{'fraction_non_alphanumeric': 0.08911116162764264, 'fraction_numerical': 0.0, 'mean_word_length': 3.174573055028463, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1998638', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1306, 'n_words': 305}