diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb
index b23d3b2..fbc589d 100644
--- a/app/controllers/candidate_controller.rb
+++ b/app/controllers/candidate_controller.rb
@@ -9,11 +9,19 @@ class CandidateController < ApplicationController
end
def update_question
- redirect_to :saved and return if params[:save] == 'Save'
+ 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.where(test_hash: '6NjnourLE6Y').first
+ @answers = @candidate.answers
+ @status = QuizStatus.new(@candidate)
+ end
+
+ def update_summary
+ redirect_to :summary
end
def thankyou
@@ -26,9 +34,9 @@ class CandidateController < ApplicationController
redirect_to :question
end
- private
-
- def question_params
- params.permit(:save)
- end
+ # private
+ #
+ # def question_params
+ # params.permit(:save)
+ # end
end
diff --git a/app/models/candidate.rb b/app/models/candidate.rb
index e2850f6..1248dd9 100644
--- a/app/models/candidate.rb
+++ b/app/models/candidate.rb
@@ -1,6 +1,6 @@
class Candidate < ApplicationRecord
belongs_to :quiz
- has_many :questions, through: :quiz
+ has_many :questions, -> { order("sort") }, through: :quiz
has_many :answers
belongs_to :recruiter, class_name: "User"
diff --git a/app/models/quiz.rb b/app/models/quiz.rb
index e1195de..b92a063 100644
--- a/app/models/quiz.rb
+++ b/app/models/quiz.rb
@@ -1,4 +1,4 @@
class Quiz < ApplicationRecord
- has_many :questions
+ has_many :questions, -> { order(:sort) }
has_many :candidates
end
diff --git a/app/views/candidate/_checkbox.html.erb b/app/views/candidate/_checkbox.html.erb
index bdc1c59..4fcd61c 100644
--- a/app/views/candidate/_checkbox.html.erb
+++ b/app/views/candidate/_checkbox.html.erb
@@ -1,20 +1,17 @@
-
+<%
+ question.input_options.each do | option |
+ option_id = "#{option.parameterize}_#{question.to_i}"
+%>
+
+
+ >
+ <%= option %>
+
+<% end %>
- <%
- @question.input_options.each do | option |
- option_id = "#{option.parameterize}_#{@question.to_i}"
- %>
-
-
- >
- <%= option %>
-
- <% end %>
-
- -- MOVE TO FLASH HASH --
-
Please select or enter an answer.
-
+-- MOVE TO FLASH HASH --
+Please select or enter an answer.
diff --git a/app/views/candidate/_live-coder.html.erb b/app/views/candidate/_live-coder.html.erb
index ba2b10e..0cab6cb 100644
--- a/app/views/candidate/_live-coder.html.erb
+++ b/app/views/candidate/_live-coder.html.erb
@@ -21,17 +21,17 @@
HTML
-
+
CSS
-
+
JS
-
+
-- MOVE TO FLASH HASH --
diff --git a/app/views/candidate/_radio.html.erb b/app/views/candidate/_radio.html.erb
index 3975252..c575a95 100644
--- a/app/views/candidate/_radio.html.erb
+++ b/app/views/candidate/_radio.html.erb
@@ -1,20 +1,17 @@
-
+<%
+ question.input_options.each do | option |
+ option_id = "#{option.parameterize}_#{question.to_i}"
+%>
+
+
+ >
+ <%= option %>
+
+<% end %>
- <%
- @question.input_options.each do | option |
- option_id = "#{option.parameterize}_#{@question.to_i}"
- %>
-
-
- >
- <%= option %>
-
- <% end %>
-
- -- MOVE TO FLASH HASH --
-
Please select or enter an answer. (The character limit for a textarea answer is 1000)
-
+-- MOVE TO FLASH HASH --
+Please select or enter an answer. (The character limit for a textarea answer is 1000)
diff --git a/app/views/candidate/_text.html.erb b/app/views/candidate/_text.html.erb
index baba253..e677c4e 100644
--- a/app/views/candidate/_text.html.erb
+++ b/app/views/candidate/_text.html.erb
@@ -1,11 +1,7 @@
-
+-- MOVE TO FLASH HASH --
+Please select or enter an answer. (The character limit for a textarea answer is 1000)
diff --git a/app/views/candidate/question.html.erb b/app/views/candidate/question.html.erb
index 636b924..af76e93 100644
--- a/app/views/candidate/question.html.erb
+++ b/app/views/candidate/question.html.erb
@@ -8,7 +8,10 @@
<%= form_tag(post_question_path) do %>
<%= @question.question %>
- <%= render partial: @question.input_type %>
+
+
+ <%= render partial: @question.input_type, locals: {question: @question, answer: @answer.answer } %>
+
<% if @status.on_summary %>
diff --git a/app/views/candidate/summary.html.erb b/app/views/candidate/summary.html.erb
index 4d178c1..ca9d652 100644
--- a/app/views/candidate/summary.html.erb
+++ b/app/views/candidate/summary.html.erb
@@ -1,2 +1,41 @@
-Candidate#summary
-Find me in app/views/candidate/summary.html.erb
+
+ Almost done!
+
+ Now's the time to review your answers and go back and change any, if you need to.
+ 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| %>
+
+
+
+
<%= question.question %>
+
+
+
+
+
+
+ <%= render partial: question.input_type, locals: {question: question, answer: @answers.where(question_id: question.id).first.answer } %>
+
+
+
+ <% end #questions loop %>
+
+ <% if @status.can_submit %>
+
+
+
+ <% else %>
+ Sorry, you must answer all questions before you can submit.
+ <% end %>
+
+ <% end #form_tag %>
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 1868c84..d88e093 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,6 +3,7 @@ Rails.application.routes.draw do
get "/thankyou", to: "candidate#thankyou", as: :thankyou
get "/saved", to: "candidate#saved", as: :saved
get "/summary", to: "candidate#summary", as: :summary
+ post "/summary", to: "candidate#update_summary", as: :post_summary
post "/question", to: "candidate#update_question", as: :post_question
get "/question", to: "candidate#question", as: :question
post "/validate", to: "candidate#validate", as: :validate_candidate