<commit_before>class QuestionsController < ApplicationController
  

  def new
    # render text: params
    @quiz = Quiz.find(params[:quiz_id])
    @question = @quiz.questions.new
  end


  def create
    # render text: params
    @quiz = Quiz.find(params[:quiz_id])
    @question = @quiz.questions.new question_params
    if @question.save
      redirect_to quiz_questions_path
    else
      render :new
    end
  end

  def show
    # render text: params
    @question = Question.find(params[:id])
    @answers = @question.answers
  end


  def index
    @quiz = Quiz.find params[:quiz_id]
    @questions = @quiz.questions.all
  end

  def edit
    @question = Question.find(params[:id])
    @quiz = @question.quiz 
  end

  def update
    # render text: params
    @question = Question.find(params[:id])
    if @question.update question_params
      redirect_to quiz_questions_path(@question.quiz)
    else :edit
    end
  end

  def destroy
    @question = Question.find(params[:id])
    @quiz = @question.quiz
    @question.destroy
    redirect_to quiz_questions_path(@quiz)
  end


  private
  def question_params 
    params.require(:question).permit(:title, :body, :explanation, :quiz_id)
  end

end<commit_msg>Reformat messy questions controller<commit_after>class QuestionsController < ApplicationController

  def new
    # render text: params
    @quiz     = Quiz.find(params[:quiz_id])
    @question = @quiz.questions.new
  end

  def create
    # render text: params
    @quiz     = Quiz.find(params[:quiz_id])
    @question = @quiz.questions.new question_params

    if @question.save
      redirect_to quiz_questions_path
    else
      render :new
    end
  end

  def show
    # render text: params
    @question = Question.find(params[:id])
    @answers  = @question.answers
  end

  def index
    @quiz      = Quiz.find params[:quiz_id]
    @questions = @quiz.questions.all
  end

  def edit
    @quiz     = @question.quiz 
    @question = Question.find(params[:id])
  end

  def update
    # render text: params
    @question = Question.find(params[:id])

    if @question.update question_params
      redirect_to quiz_questions_path(@question.quiz)
    else :edit
    end
  end

  def destroy
    @question = Question.find(params[:id])
    @quiz     = @question.quiz

    @question.destroy
    redirect_to quiz_questions_path(@quiz)
  end

  private

  def question_params 
    params.require(:question).permit(:title, :body, :explanation, :quiz_id)
  end

end
{'fraction_non_alphanumeric': 0.09822866344605476, 'fraction_numerical': 0.0, 'mean_word_length': 2.9319620253164556, 'pattern_counts': {'":': 0, '<': 5, '<?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': '808447', 'n_tokens_mistral': 849, 'n_tokens_neox': 794, 'n_words': 186}