<commit_before>class AdminController < ApplicationController
	before_action :authenticate_admin

	def index

	end

	def admin_users
		@users = User.all.order(:level).reverse_order
		@user = User.new
		@levels = User.levels
	end

	def create_user
		@user = User.new(user_params)
		@user.name = @user.name.downcase if @user.name
		UserMailer.welcome_email(@user).deliver_later if @user.save
		redirect_to admin_users_path
	end

	def delete_user
		@user = User.find(params[:id])
		@user.destroy
		redirect_to admin_users_path
	end

	def edit_user
		@user = User.find(params[:id])
		@levels = User.levels
	end

	def update_user
		@user = User.find(params[:id])
		@user.update_attributes(user_params)
		@user.save
		redirect_to admin_users_path
	end

	def admin_exams
		@exam = Exam.new
		@exams = Exam.order_by_position
		@levels = Exam.levels
	end

	def create_exam
		@exam = Exam.new(exam_params)
		@exam.save
		redirect_to admin_exams_path
	end

	def edit_exam
		@exam = Exam.find(params[:id])
		@levels = Exam.levels
	end

	def update_exam
		@exam = Exam.find(params[:id])
		@exam.update_attributes(exam_params)
		@exam.save
		redirect_to admin_exams_path
	end

	def delete_exam
		@exam = Exam.find(params[:id])
		@exam.destroy
		redirect_to admin_exams_path
	end

	def new_question
		@exam = Exam.find(params[:id])
		@question = Question.new
	end

	def create_question
		@question = Question.new(question_params)
		@question.exam_id = params[:id]
		@question.save
		redirect_to exam_questions_path(@question.exam_id)
	end

	def exam_questions
		@exam = Exam.find(params[:id])
		@questions = @exam.questions
	end

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

	def update_question
		@question = Question.find(params[:id])
		@question.update_attributes(question_params)
		redirect_to exam_questions_path(@question.exam_id)
	end

	def delete_question
		@question = Question.find(params[:id])
		@exam = Exam.find(@question.exam_id)
		@question.destroy
		redirect_to exam_questions_path(@exam)
	end

	def preview_exam
		@exam = Exam.find(params[:id])
		@video = @exam.video_id
		@questions = @exam.questions
	end

	def new_answer
		@question = Question.find(params[:id])
		@answer = Answer.new
	end

	def create_answer
		@question = Question.find(params[:id])
		@answer = Answer.new(answer_params)
		@answer.question_id = @question.id
		@answer.save
		redirect_to exam_questions_path(@question.exam_id)
	end

	private

		def user_params
			params.require(:user).permit(:email, :name, :password_digest, :level)
		end<commit_msg>Added method for edit answer<commit_after>class AdminController < ApplicationController
	before_action :authenticate_admin

	def index

	end

	def admin_users
		@users = User.all.order(:level).reverse_order
		@user = User.new
		@levels = User.levels
	end

	def create_user
		@user = User.new(user_params)
		@user.name = @user.name.downcase if @user.name
		UserMailer.welcome_email(@user).deliver_later if @user.save
		redirect_to admin_users_path
	end

	def delete_user
		@user = User.find(params[:id])
		@user.destroy
		redirect_to admin_users_path
	end

	def edit_user
		@user = User.find(params[:id])
		@levels = User.levels
	end

	def update_user
		@user = User.find(params[:id])
		@user.update_attributes(user_params)
		@user.save
		redirect_to admin_users_path
	end

	def admin_exams
		@exam = Exam.new
		@exams = Exam.order_by_position
		@levels = Exam.levels
	end

	def create_exam
		@exam = Exam.new(exam_params)
		@exam.save
		redirect_to admin_exams_path
	end

	def edit_exam
		@exam = Exam.find(params[:id])
		@levels = Exam.levels
	end

	def update_exam
		@exam = Exam.find(params[:id])
		@exam.update_attributes(exam_params)
		@exam.save
		redirect_to admin_exams_path
	end

	def delete_exam
		@exam = Exam.find(params[:id])
		@exam.destroy
		redirect_to admin_exams_path
	end

	def new_question
		@exam = Exam.find(params[:id])
		@question = Question.new
	end

	def create_question
		@question = Question.new(question_params)
		@question.exam_id = params[:id]
		@question.save
		redirect_to exam_questions_path(@question.exam_id)
	end

	def exam_questions
		@exam = Exam.find(params[:id])
		@questions = @exam.questions
	end

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

	def update_question
		@question = Question.find(params[:id])
		@question.update_attributes(question_params)
		redirect_to exam_questions_path(@question.exam_id)
	end

	def delete_question
		@question = Question.find(params[:id])
		@exam = Exam.find(@question.exam_id)
		@question.destroy
		redirect_to exam_questions_path(@exam)
	end

	def preview_exam
		@exam = Exam.find(params[:id])
		@video = @exam.video_id
		@questions = @exam.questions
	end

	def new_answer
		@question = Question.find(params[:id])
		@answer = Answer.new
	end

	def create_answer
		@question = Question.find(params[:id])
		@answer = Answer.new(answer_params)
		@answer.question_id = @question.id
		@answer.save
		redirect_to exam_questions_path(@question.exam_id)
	end

	def edit_answer
		@answer = Answer.find(params[:id])
		@question = Question.find(@answer.question_id)
	end

	def update_answer
	end

	private

		def user_params
			params.require(:user).permit(:email, :name, :password_digest, :level)
		end
{'fraction_non_alphanumeric': 0.10754536771728748, 'fraction_numerical': 0.0, 'mean_word_length': 4.5, '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': '802186', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1914, 'n_words': 371}