split login/welcome and added direct link welcome

This commit is contained in:
Mark Moser 2016-08-02 18:02:20 -05:00
parent 7bdb86f89f
commit 737fd10636
9 changed files with 125 additions and 85 deletions

View File

@ -30,6 +30,6 @@ class ApplicationController < ActionController::Base
end end
def authorize_candidate def authorize_candidate
redirect_to welcome_path unless current_candidate redirect_to login_path unless current_candidate
end end
end end

View File

@ -1,5 +1,14 @@
class CandidateController < ApplicationController class CandidateController < ApplicationController
before_action :authorize_candidate, except: [:welcome, :validate, :live_coder] before_action :authorize_candidate, except: [:login, :validate, :live_coder]
before_action :send_to_oops, only: [:login]
def login
login_candidate
redirect_to :thankyou and return if current_candidate && current_candidate.completed?
redirect_to :welcome if current_candidate
flash[:error] = "Sorry, incorrect test id" if params[:test_hash].present?
end
def welcome def welcome
end end
@ -7,6 +16,9 @@ class CandidateController < ApplicationController
def saved def saved
end end
def oops
end
def thankyou def thankyou
redirect_to root_path if session[:test_id].nil? redirect_to root_path if session[:test_id].nil?
reset_session reset_session
@ -52,11 +64,22 @@ class CandidateController < ApplicationController
session[:test_id] = candidate.test_hash session[:test_id] = candidate.test_hash
redirect_to :thankyou and return if candidate.completed? redirect_to :thankyou and return if candidate.completed?
redirect_to :question redirect_to :welcome
end end
private private
def login_candidate
candidate = Candidate.find_by(test_hash: params['test_id'])
return false if candidate.nil?
session[:test_id] = candidate.test_hash
end
def send_to_oops
redirect_to oops_path if current_candidate
end
def prep_question qid def prep_question qid
@question = current_candidate.fetch_question(qid) @question = current_candidate.fetch_question(qid)
end end

View File

@ -0,0 +1,20 @@
<% content_for :title, "Skills Assessment" %>
<main class="intro_tpl">
<h1 class="prft-heading">Let's Get Started</h1>
<p>
Hey there! Give us your test id, and we'll get you started.
</p>
<%= form_tag(validate_candidate_path) do %>
<div class="form-group">
<label for="userid">What's your Test ID?</label>
<input type="text" id="test_id" name="test_id" required/>
<% if flash[:error].present? %>
<div class="error"><%= flash[:error] %></div>
<% end %>
</div>
<button type="submit">Login</button>
<% end %>
</main>

View File

@ -0,0 +1,9 @@
<main class="intro_tpl">
<h1 class="prft-heading">Oops!</h1>
<p>
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.
</p>
<a href="<%= question_path %>"><button>Continue Test</button></a>
</main>

View File

@ -1,50 +1,26 @@
<% content_for :title, "Skills Assessment" %> <% content_for :title, "Skills Assessment" %>
<% if session[:test_id].present? %> <main class="intro_tpl">
<h1 class="prft-heading">Welcome!</h1>
<p>
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.
</p>
<p>
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,
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
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.
</p>
<p>
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
answers, we will review your assessment and your recruiter will be in touch.
</p>
<main class="intro_tpl"> <%= link_to question_path do %>
<h1 class="prft-heading">Oops!</h1> <button type="submit">Begin</button>
<p> <% end %>
Looks like you hit the browser's Back button. You can't go backwards in the test, </main>
but you'll have a chance at the end to review your answers and make changes.
</p>
<a href="<%= question_path %>"><button>Continue Test</button></a>
</main>
<% else %>
<main class="intro_tpl">
<h1 class="prft-heading">Let's Get Started</h1>
<p>
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.
</p>
<p>
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,
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
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.
</p>
<p>
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
answers, we will review your assessment and your recruiter will be in touch.
</p>
<%= form_tag(validate_candidate_path) do %>
<div class="form-group">
<label for="userid">What's your User ID?</label>
<input type="text" id="test_id" name="test_id" required/>
<% if flash[:error].present? %>
<div class="error"><%= flash[:error] %></div>
<% end %>
</div>
<button type="submit">Begin</button>
<% end %>
</main>
<% end %>

View File

@ -17,9 +17,10 @@
<td style="padding:15px 20px; background-color:#cdcdcd; text-align:center;"> <td style="padding:15px 20px; background-color:#cdcdcd; text-align:center;">
<h4> <h4>
Please visit <%= link_to nil, root_url %> Please visit <%= link_to nil, login_url(@candidate.test_hash) %> to get started.
and enter the above Candidate ID to being your test.
</h4> </h4>
<p>If you would rather, visit <%= link_to nil, root_url %>
and enter the above Candidate ID to being your test.</p>
<h5>We will reach back to you once we have evaluated your answers. Good luck!</h5> <h5>We will reach back to you once we have evaluated your answers. Good luck!</h5>
</td> </td>

View File

@ -1,10 +1,9 @@
PERFICIENT DIGITAL - Skills Assessment Test PERFICIENT DIGITAL - Skills Assessment Test
Your Candidate ID is <%= @candidate.test_hash %> Please visit <%= login_url(@candidate.test_hash) %> to get started.
Please visit <%= root_url %> Or, visit <%= root_url %> and enter your Candidate ID to being your test.
and enter the above Candidate ID to being your test. Your Candidate ID is: <%= @candidate.test_hash %>
We will reach back to you once we have evaluated your answers. We will reach back to you once we have evaluated your answers.
Good luck! Good luck!

View File

@ -1,30 +1,32 @@
Rails.application.routes.draw do Rails.application.routes.draw do
post "/validate", to: "candidate#validate", as: :validate_candidate post "/validate", to: "candidate#validate", as: :validate_candidate
get "/welcome", to: "candidate#welcome", as: :welcome get "/login(/:test_id)", to: "candidate#login", as: :login
get "/thankyou", to: "candidate#thankyou", as: :thankyou get "/welcome", to: "candidate#welcome", as: :welcome
get "/saved", to: "candidate#saved", as: :saved get "/saved", to: "candidate#saved", as: :saved
get "/thankyou", to: "candidate#thankyou", as: :thankyou
get "/oops", to: "candidate#oops", as: :oops
post "/question(/:answer_id)", to: "candidate#update_answer", as: :post_answer post "/question(/:answer_id)", to: "candidate#update_answer", as: :post_answer
get "/question(/:question_id)", to: "candidate#question", as: :question get "/question(/:question_id)", to: "candidate#question", as: :question
get "/live-coder-entry/:question_id", to: "candidate#live_coder", as: :live_coder get "/live-coder-entry/:question_id", to: "candidate#live_coder", as: :live_coder
post "/summary", to: "candidate#update_summary", as: :post_summary post "/summary", to: "candidate#update_summary", as: :post_summary
get "/summary", to: "candidate#summary", as: :summary get "/summary", to: "candidate#summary", as: :summary
get "/review/logout", to: "review#logout", as: :review_logout get "/review/logout", to: "review#logout", as: :review_logout
post "/review/login", to: "review#auth", as: :review_auth post "/review/login", to: "review#auth", as: :review_auth
get "/review/login", to: "review#login", as: :review_login get "/review/login", to: "review#login", as: :review_login
get "/review", to: "review#index", as: :review get "/review", to: "review#index", as: :review
get "/review/:test_hash", to: "review#view", as: :review_test get "/review/:test_hash", to: "review#view", as: :review_test
get "/recruiter", to: "recruiter#index", as: :recruiter get "/recruiter", to: "recruiter#index", as: :recruiter
get "/recruiter/new-candidate", to: "recruiter#new", as: :new_candidate get "/recruiter/new-candidate", to: "recruiter#new", as: :new_candidate
post "/recruiter/new-candidate", to: "recruiter#create", as: :create_candidate post "/recruiter/new-candidate", to: "recruiter#create", as: :create_candidate
get "/recruiter/logout", to: "recruiter#logout", as: :recruiter_logout get "/recruiter/logout", to: "recruiter#logout", as: :recruiter_logout
get "/recruiter/login", to: "recruiter#login", as: :recruiter_login get "/recruiter/login", to: "recruiter#login", as: :recruiter_login
post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth
root to: "candidate#welcome" root to: "candidate#login"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end end

View File

@ -6,32 +6,42 @@ class CandidateControllerTest < ActionDispatch::IntegrationTest
end end
test "should get login" do test "should get login" do
get welcome_path get login_path
assert_response :success assert_response :success
refute flash[:error].present?, "Should not be displaying an error message"
end end
test "should require auth and redirect" do test "should require auth and redirect" do
get saved_path get saved_path
assert_redirected_to welcome_path assert_redirected_to login_path
get thankyou_path get thankyou_path
assert_redirected_to welcome_path assert_redirected_to login_path
get summary_path get summary_path
assert_redirected_to welcome_path assert_redirected_to login_path
get question_path get question_path
assert_redirected_to welcome_path assert_redirected_to login_path
get question_path(questions(:fed1).id) get question_path(questions(:fed1).id)
assert_redirected_to welcome_path assert_redirected_to login_path
end end
test "should auth to question" do test "should auth to welcome" do
setup_auth candidates(:martha) setup_auth candidates(:martha)
assert_redirected_to question_path assert_redirected_to welcome_path
assert session[:test_id].present? assert session[:test_id].present?
refute flash[:error].present?, "Should not be displaying an error message"
end
test "should auth directly to welcome" do
get login_path(candidates(:martha).test_hash)
assert_redirected_to welcome_path
assert session[:test_id].present?
refute flash[:error].present?, "Should not be displaying an error message"
end end
test "should redirect to thankyou when completed" do test "should redirect to thankyou when completed" do