skill-assessment-app/app/controllers/candidate_controller.rb

50 lines
1.0 KiB
Ruby
Raw Normal View History

2016-07-27 22:16:12 -05:00
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')
2016-07-27 22:16:12 -05:00
end
2016-07-28 08:47:34 -05:00
def update_question
2016-07-28 20:54:08 -05:00
redirect_to :summary and return if params.key?(:update)
redirect_to :saved and return if params.key?(:save)
2016-07-28 08:47:34 -05:00
redirect_to :question
end
2016-07-27 22:16:12 -05:00
def summary
@candidate = Candidate.order("RAND()").first # Candidate.where(test_hash: '6NjnourLE6Y').first
@quiz = @candidate.my_quiz
2016-07-28 20:54:08 -05:00
@status = QuizStatus.new(@candidate)
end
def update_summary
redirect_to :summary
2016-07-27 22:16:12 -05:00
end
def thankyou
end
def saved
end
2016-07-28 08:47:34 -05:00
def validate
redirect_to :question
end
2016-07-28 09:37:46 -05:00
2016-07-29 11:00:04 -05:00
def live_coder
@question = Question.find(params[:question_id])
@answer = @question.answers.order("RAND()").first.answer
render layout: false
end
2016-07-28 20:54:08 -05:00
# private
#
# def question_params
# params.permit(:save)
# end
2016-07-27 22:16:12 -05:00
end