diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1c07694..7bd799d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
+
+ def current_candidate
+ @current_candidate ||= Candidate.find_by(test_hash: session[:test_id])
+ end
end
diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb
index fd3d445..484c9d3 100644
--- a/app/controllers/candidate_controller.rb
+++ b/app/controllers/candidate_controller.rb
@@ -26,13 +26,23 @@ class CandidateController < ApplicationController
end
def thankyou
+ redirect_to root_path if session[:test_id].nil?
+ reset_session
end
def saved
end
def validate
- redirect_to :question
+ candidate = Candidate.find_by(test_hash: params['test_id'])
+
+ if candidate.nil?
+ reset_session
+ redirect_to root_path, alert: "Sorry, incorrect test id"
+ else
+ session[:test_id] = candidate.test_hash
+ redirect_to :question
+ end
end
def live_coder
@@ -41,9 +51,9 @@ class CandidateController < ApplicationController
render layout: false
end
- # private
- #
- # def question_params
- # params.permit(:save)
- # end
+ private
+
+ def question_params
+ params.permit(:save)
+ end
end
diff --git a/app/views/candidate/welcome.html.erb b/app/views/candidate/welcome.html.erb
index f1f4e75..ae4fe34 100644
--- a/app/views/candidate/welcome.html.erb
+++ b/app/views/candidate/welcome.html.erb
@@ -1,44 +1,46 @@
<% content_for :title, "Skills Assessment" %>
-
+<% if session[:test_id].present? %>
-
-
Oops!
-
- Looks like you hit the browser's Back button. You can't go backwards in the test,
- but you'll have a chance at the end to review your answers and make changes.
-
+
+
Oops!
+
+ Looks like you hit the browser's Back button. You can't go backwards in the test,
+ but you'll have a chance at the end to review your answers and make changes.
+
-
-
+
+
-
+<% else %>
-
-
Let's Get Started
-
- This is a skills assessment test. It's the first step in the process of interviewing
- for a Front-End Development position with Perficient Digital.
-
-
- The questions will test your knowledge in the areas of HTML, CSS, and JavaScript.
- Please note that you can only move forward through the test, not back,
- and you must attempt to answer the question before moving to the
- next one. You'll have an opportunity at the end of the test to review and update your
- answers if need be. At any time, you may save your progress and log back in to continue
- taking the test from where you left off.
-
-
- Please answer to the best of your ability—it's totally okay to say
- "I don't know"!—and above all, relax and have fun! Once you submit your
- answers, we will review your assessment and your recruiter will be in touch.
-
+
+
Let's Get Started
+
+ This is a skills assessment test. It's the first step in the process of interviewing
+ for a Front-End Development position with Perficient Digital.
+
+
+ The questions will test your knowledge in the areas of HTML, CSS, and JavaScript.
+ Please note that you can only move forward through the test, not back,
+ and you must attempt to answer the question before moving to the
+ next one. You'll have an opportunity at the end of the test to review and update your
+ answers if need be. At any time, you may save your progress and log back in to continue
+ taking the test from where you left off.
+
+
+ Please answer to the best of your ability—it's totally okay to say
+ "I don't know"!—and above all, relax and have fun! Once you submit your
+ answers, we will review your assessment and your recruiter will be in touch.
+
- <%= form_tag(validate_candidate_path) do %>
-
-
-
-
-
- <% end %>
-
+ <%= form_tag(validate_candidate_path) do %>
+