50 lines
1.0 KiB
Ruby
50 lines
1.0 KiB
Ruby
class CandidateController < ApplicationController
|
|
def welcome
|
|
end
|
|
|
|
def question
|
|
candidate = Candidate.order("RAND()").first
|
|
@status = QuizStatus.new(candidate)
|
|
@question = candidate.fetch_question(candidate.questions.order("RAND()")[[*0..9].sample].id)
|
|
# .where(input_type: 'live-coder')
|
|
end
|
|
|
|
def update_question
|
|
redirect_to :summary and return if params.key?(:update)
|
|
redirect_to :saved and return if params.key?(:save)
|
|
redirect_to :question
|
|
end
|
|
|
|
def summary
|
|
@candidate = Candidate.order("RAND()").first # Candidate.where(test_hash: '6NjnourLE6Y').first
|
|
@quiz = @candidate.my_quiz
|
|
@status = QuizStatus.new(@candidate)
|
|
end
|
|
|
|
def update_summary
|
|
redirect_to :summary
|
|
end
|
|
|
|
def thankyou
|
|
end
|
|
|
|
def saved
|
|
end
|
|
|
|
def validate
|
|
redirect_to :question
|
|
end
|
|
|
|
def live_coder
|
|
@question = Question.find(params[:question_id])
|
|
@answer = @question.answers.order("RAND()").first.answer
|
|
render layout: false
|
|
end
|
|
|
|
# private
|
|
#
|
|
# def question_params
|
|
# params.permit(:save)
|
|
# end
|
|
end
|