diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb index fbc589d..336405a 100644 --- a/app/controllers/candidate_controller.rb +++ b/app/controllers/candidate_controller.rb @@ -3,9 +3,10 @@ class CandidateController < ApplicationController end def question - @question = Question.order("RAND()").first # .where(input_type: 'live-coder') - @status = QuizStatus.new(Candidate.order("RAND()").first) - @answer = @question.answers.order("RAND()").first + 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 @@ -15,8 +16,8 @@ class CandidateController < ApplicationController end def summary - @candidate = Candidate.where(test_hash: '6NjnourLE6Y').first - @answers = @candidate.answers + @candidate = Candidate.order("RAND()").first # Candidate.where(test_hash: '6NjnourLE6Y').first + @quiz = @candidate.my_quiz @status = QuizStatus.new(@candidate) end diff --git a/app/views/candidate/_checkbox.html.erb b/app/views/candidate/_checkbox.html.erb index 4fcd61c..96d1e11 100644 --- a/app/views/candidate/_checkbox.html.erb +++ b/app/views/candidate/_checkbox.html.erb @@ -7,7 +7,7 @@ name="input_checkbox_<%= question.to_i %>[]" id="check_<%= option_id %>" value="<%= option %>" - <%= "checked=\"checked\"" if Array(answer).include?(option) %> + <%= "checked=\"checked\"" if Array(question.answer).include?(option) %> > diff --git a/app/views/candidate/_live-coder.html.erb b/app/views/candidate/_live-coder.html.erb index 0cab6cb..bd96518 100644 --- a/app/views/candidate/_live-coder.html.erb +++ b/app/views/candidate/_live-coder.html.erb @@ -21,17 +21,17 @@
- +
- +
- +
-- MOVE TO FLASH HASH -- diff --git a/app/views/candidate/_radio.html.erb b/app/views/candidate/_radio.html.erb index c575a95..d5e124e 100644 --- a/app/views/candidate/_radio.html.erb +++ b/app/views/candidate/_radio.html.erb @@ -7,7 +7,7 @@ name="input_radio_<%= question.to_i %>" id="radio_<%= option_id %>" value="<%= option %>" - <%= "checked=\"checked\"" if answer == option %> + <%= "checked=\"checked\"" if question.answer == option %> > diff --git a/app/views/candidate/_text.html.erb b/app/views/candidate/_text.html.erb index e677c4e..bf1a8f0 100644 --- a/app/views/candidate/_text.html.erb +++ b/app/views/candidate/_text.html.erb @@ -1,5 +1,5 @@ - +
Characters remaining:
diff --git a/app/views/candidate/question.html.erb b/app/views/candidate/question.html.erb index af76e93..1c935a6 100644 --- a/app/views/candidate/question.html.erb +++ b/app/views/candidate/question.html.erb @@ -10,7 +10,7 @@

<%= @question.question %>

- <%= render partial: @question.input_type, locals: {question: @question, answer: @answer.answer } %> + <%= render partial: @question.input_type, locals: {question: @question} %>
<% if @status.on_summary %> diff --git a/app/views/candidate/summary.html.erb b/app/views/candidate/summary.html.erb index ca9d652..f0ba7bc 100644 --- a/app/views/candidate/summary.html.erb +++ b/app/views/candidate/summary.html.erb @@ -5,16 +5,15 @@ Once you're done, hit the button at the bottom of the page to submit your answers.

- <%= form_tag(post_summary_path) do %> - <% @candidate.quiz.questions.each do |question| %> + <% @quiz.each do |question| %>

<%= question.question %>

- Edit + Edit
@@ -22,7 +21,7 @@
- <%= render partial: question.input_type, locals: {question: question, answer: @answers.where(question_id: question.id).first.answer } %> + <%= render partial: question.input_type, locals: {question: question} %>