');
diff --git a/app/assets/stylesheets/molecules/_forms.scss b/app/assets/stylesheets/molecules/_forms.scss
index 6a0ed63..f48ee86 100644
--- a/app/assets/stylesheets/molecules/_forms.scss
+++ b/app/assets/stylesheets/molecules/_forms.scss
@@ -29,6 +29,10 @@ label {
font-weight: 300;
}
+form.btn-center {
+ text-align: center;
+}
+
#{$all-text-inputs} {
display: block;
font-size: $base-font-size;
diff --git a/app/controllers/quiz_controller.rb b/app/controllers/quiz_controller.rb
index 1b50e63..ded3f47 100644
--- a/app/controllers/quiz_controller.rb
+++ b/app/controllers/quiz_controller.rb
@@ -11,9 +11,10 @@ class QuizController < ApplicationController
def update_answer
@answer = prep_answer answer_params[:question_id]
+ prep_status
send "process_#{prep_question(answer_params[:question_id]).input_type}"
- route_remote and return if request.xhr?
- route_answer
+ route_answer_xhr and return if request.xhr?
+ route_answer_html
end
def summary
@@ -21,11 +22,10 @@ class QuizController < ApplicationController
redirect_to :question and return unless prep_status.current_question_id.nil?
end
- def update_summary
- prep_status
+ def submit_summary
not_completed_error = 'You must complete all questions to submit your test.'
record_error = 'There was a problem with your submission. Please try again later.'
- redirect_to :summary, flash: { error: not_completed_error } and return unless @status.can_submit
+ redirect_to :summary, flash: { error: not_completed_error } and return unless prep_status.can_submit
redirect_to :thankyou and return if current_candidate.complete!
redirect_to :summary, flash: { error: record_error }
end
@@ -62,9 +62,8 @@ class QuizController < ApplicationController
answer
end
- def route_answer
+ def route_answer_html
if @answer.errors.present?
- prep_status
prep_question answer_params[:question_id]
flash[:error] = answer_params[:question_id].to_i
render :question
@@ -75,11 +74,16 @@ class QuizController < ApplicationController
end
end
- def route_remote
+ def route_answer_xhr
if @answer.errors.present?
render json: @answer.errors["answer"].to_json, status: 400
else
- render json: { message: "Your answer has been updated successfully!" }.to_json
+ results = {
+ message: "Your answer has been updated successfully!",
+ can_submit: prep_status.can_submit,
+ progress: prep_status.progress
+ }
+ render json: results.to_json
end
end
diff --git a/app/views/quiz/summary.html.erb b/app/views/quiz/summary.html.erb
index a6d3f02..dedf86c 100644
--- a/app/views/quiz/summary.html.erb
+++ b/app/views/quiz/summary.html.erb
@@ -43,11 +43,10 @@
<% end %>
<% end %>
- <% if @status.can_submit %>
- <%= form_tag post_summary_path, class: "btn-container-right" do %>
-
+ <%= form_tag post_summary_path, id: 'summary-submit', class: "btn-center" do %>
+ <% unless @status.can_submit %>
+
Sorry, you must answer all questions before you can submit.
<% end %>
- <% else %>
-
Sorry, you must answer all questions before you can submit.
+ <%= submit_tag "Submit all answers", {class: 'submit-button', disabled: !@status.can_submit } %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 847837f..b245523 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
post "/question(/:answer_id)", to: "quiz#update_answer", as: :post_answer
get "/question(/:question_id)", to: "quiz#question", as: :question
- post "/summary", to: "quiz#update_summary", as: :post_summary
+ post "/summary", to: "quiz#submit_summary", as: :post_summary
get "/summary", to: "quiz#summary", as: :summary
get "/review/logout", to: "review#logout", as: :review_logout