candidate login/logout

This commit is contained in:
Mark Moser 2016-07-29 11:53:01 -05:00
parent df8c31403c
commit 484766a377
3 changed files with 59 additions and 43 deletions

View File

@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
def current_candidate
@current_candidate ||= Candidate.find_by(test_hash: session[:test_id])
end
end end

View File

@ -26,13 +26,23 @@ class CandidateController < ApplicationController
end end
def thankyou def thankyou
redirect_to root_path if session[:test_id].nil?
reset_session
end end
def saved def saved
end end
def validate 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 end
def live_coder def live_coder
@ -41,9 +51,9 @@ class CandidateController < ApplicationController
render layout: false render layout: false
end end
# private private
#
# def question_params def question_params
# params.permit(:save) params.permit(:save)
# end end
end end

View File

@ -1,44 +1,46 @@
<% content_for :title, "Skills Assessment" %> <% content_for :title, "Skills Assessment" %>
<!-- if (isset($_SESSION['candidateId'])) { ?> --> <% if session[:test_id].present? %>
<main class="intro_tpl"> <main class="intro_tpl">
<h1 class="prft-heading">Oops!</h1> <h1 class="prft-heading">Oops!</h1>
<p> <p>
Looks like you hit the browser's Back button. You can't go backwards in the test, 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. but you'll have a chance at the end to review your answers and make changes.
</p> </p>
<a href="<%= question_path %>"><button>Continue Test</button></a> <a href="<%= question_path %>"><button>Continue Test</button></a>
</main> </main>
<!-- <?php } else { ?> --> <% else %>
<main class="intro_tpl"> <main class="intro_tpl">
<h1 class="prft-heading">Let's Get Started</h1> <h1 class="prft-heading">Let's Get Started</h1>
<p> <p>
This is a skills assessment test. It's the first step in the process of interviewing 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. for a Front-End Development position with Perficient Digital.
</p> </p>
<p> <p>
The questions will test your knowledge in the areas of HTML, CSS, and JavaScript. The questions will test your knowledge in the areas of HTML, CSS, and JavaScript.
Please note that you can <strong>only move forward through the test</strong>, not back, Please note that you can <strong>only move forward through the test</strong>, not back,
and you <strong>must attempt to answer the question</strong> before moving to the and you <strong>must attempt to answer the question</strong> before moving to the
next one. You'll have an opportunity at the end of the test to review and update your 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 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. taking the test from where you left off.
</p> </p>
<p> <p>
Please answer to the best of your ability&mdash;it's totally okay to say Please answer to the best of your ability&mdash;it's totally okay to say
"I don't know"!&mdash;and above all, relax and have fun! Once you submit your "I don't know"!&mdash;and above all, relax and have fun! Once you submit your
answers, we will review your assessment and your recruiter will be in touch. answers, we will review your assessment and your recruiter will be in touch.
</p> </p>
<%= form_tag(validate_candidate_path) do %> <%= form_tag(validate_candidate_path) do %>
<div class="form-group"> <div class="form-group">
<label for="userid">What's your User ID?</label> <label for="userid">What's your User ID?</label>
<input type="text" id="userId" name="userId" required/> <input type="text" id="test_id" name="test_id" required/>
</div> </div>
<button type="submit">Begin</button> <button type="submit">Begin</button>
<% end %> <% end %>
</main> </main>
<% end %>