summary roughed in
This commit is contained in:
parent
f9930ce531
commit
3a1c7de698
@ -9,11 +9,19 @@ class CandidateController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_question
|
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
|
redirect_to :question
|
||||||
end
|
end
|
||||||
|
|
||||||
def summary
|
def summary
|
||||||
|
@candidate = Candidate.where(test_hash: '6NjnourLE6Y').first
|
||||||
|
@answers = @candidate.answers
|
||||||
|
@status = QuizStatus.new(@candidate)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_summary
|
||||||
|
redirect_to :summary
|
||||||
end
|
end
|
||||||
|
|
||||||
def thankyou
|
def thankyou
|
||||||
@ -26,9 +34,9 @@ class CandidateController < ApplicationController
|
|||||||
redirect_to :question
|
redirect_to :question
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
# private
|
||||||
|
#
|
||||||
def question_params
|
# def question_params
|
||||||
params.permit(:save)
|
# params.permit(:save)
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class Candidate < ApplicationRecord
|
class Candidate < ApplicationRecord
|
||||||
belongs_to :quiz
|
belongs_to :quiz
|
||||||
has_many :questions, through: :quiz
|
has_many :questions, -> { order("sort") }, through: :quiz
|
||||||
has_many :answers
|
has_many :answers
|
||||||
belongs_to :recruiter, class_name: "User"
|
belongs_to :recruiter, class_name: "User"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Quiz < ApplicationRecord
|
class Quiz < ApplicationRecord
|
||||||
has_many :questions
|
has_many :questions, -> { order(:sort) }
|
||||||
has_many :candidates
|
has_many :candidates
|
||||||
end
|
end
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
<div class="content-well">
|
<%
|
||||||
|
question.input_options.each do | option |
|
||||||
|
option_id = "#{option.parameterize}_#{question.to_i}"
|
||||||
|
%>
|
||||||
|
<div class="form-group-multiples">
|
||||||
|
<input type="checkbox" class="checkbox"
|
||||||
|
name="input_checkbox_<%= question.to_i %>[]"
|
||||||
|
id="check_<%= option_id %>"
|
||||||
|
value="<%= option %>"
|
||||||
|
<%= "checked=\"checked\"" if Array(answer).include?(option) %>
|
||||||
|
>
|
||||||
|
<label for="check_<%= option_id %>"><%= option %></label>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%
|
-- MOVE TO FLASH HASH --
|
||||||
@question.input_options.each do | option |
|
<div class="error">Please select or enter an answer.</div>
|
||||||
option_id = "#{option.parameterize}_#{@question.to_i}"
|
|
||||||
%>
|
|
||||||
<div class="form-group-multiples">
|
|
||||||
<input type="checkbox" class="checkbox"
|
|
||||||
name="input_checkbox_<%= @question.to_i %>[]"
|
|
||||||
id="check_<%= option_id %>"
|
|
||||||
value="<%= option %>"
|
|
||||||
<%= "checked=\"checked\"" if Array(@answer.answer).include?(option) %>
|
|
||||||
>
|
|
||||||
<label for="check_<%= option_id %>"><%= option %></label>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
-- MOVE TO FLASH HASH --
|
|
||||||
<div class="error">Please select or enter an answer.</div>
|
|
||||||
</div>
|
|
||||||
|
@ -21,17 +21,17 @@
|
|||||||
|
|
||||||
<div class="code-input">
|
<div class="code-input">
|
||||||
<label for="code-html">HTML</label>
|
<label for="code-html">HTML</label>
|
||||||
<textarea data-id="code-html" name="code-html"><%= @answer.answer.try(:[], ['html']) %></textarea>
|
<textarea data-id="code-html" name="code-html"><%= answer['html'] unless answer.nil? %></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="code-input">
|
<div class="code-input">
|
||||||
<label for="code-css">CSS</label>
|
<label for="code-css">CSS</label>
|
||||||
<textarea data-id="code-css" name="code-css"><%= @answer.answer.try(:[], ['css']) %></textarea>
|
<textarea data-id="code-css" name="code-css"><%= answer['css'] unless answer.nil? %></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="code-input">
|
<div class="code-input">
|
||||||
<label for="code-js">JS</label>
|
<label for="code-js">JS</label>
|
||||||
<textarea data-id="code-js" name="code-js"><%= @answer.answer.try(:[], ['js']) %></textarea>
|
<textarea data-id="code-js" name="code-js"><%= answer['js'] unless answer.nil? %></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
-- MOVE TO FLASH HASH --
|
-- MOVE TO FLASH HASH --
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
<div class="content-well">
|
<%
|
||||||
|
question.input_options.each do | option |
|
||||||
|
option_id = "#{option.parameterize}_#{question.to_i}"
|
||||||
|
%>
|
||||||
|
<div class="form-group-multiples">
|
||||||
|
<input type="radio" class="radio"
|
||||||
|
name="input_radio_<%= question.to_i %>"
|
||||||
|
id="radio_<%= option_id %>"
|
||||||
|
value="<%= option %>"
|
||||||
|
<%= "checked=\"checked\"" if answer == option %>
|
||||||
|
>
|
||||||
|
<label for="radio_<%= option_id %>"><%= option %></label>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%
|
-- MOVE TO FLASH HASH --
|
||||||
@question.input_options.each do | option |
|
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||||
option_id = "#{option.parameterize}_#{@question.to_i}"
|
|
||||||
%>
|
|
||||||
<div class="form-group-multiples">
|
|
||||||
<input type="radio" class="radio"
|
|
||||||
name="input_radio_<%= @question.to_i %>"
|
|
||||||
id="radio_<%= option_id %>"
|
|
||||||
value="<%= option %>"
|
|
||||||
<%= "checked=\"checked\"" if @answer.answer == option %>
|
|
||||||
>
|
|
||||||
<label for="radio_<%= option_id %>"><%= option %></label>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
-- MOVE TO FLASH HASH --
|
|
||||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
|
||||||
</div>
|
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
<div class="form-group">
|
<label for="textArea">Enter answer here</label>
|
||||||
|
<textarea id="textArea" name="textarea" rows="10"><%= answer %></textarea>
|
||||||
|
|
||||||
<label for="textArea">Enter answer here</label>
|
<div class="chars">Characters remaining: <span></span></div>
|
||||||
<textarea id="textArea" name="textarea" rows="10"><%= @answer.answer %></textarea>
|
|
||||||
|
|
||||||
<div class="chars">Characters remaining: <span></span></div>
|
-- MOVE TO FLASH HASH --
|
||||||
|
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||||
-- MOVE TO FLASH HASH --
|
|
||||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
@ -8,7 +8,10 @@
|
|||||||
<%= form_tag(post_question_path) do %>
|
<%= form_tag(post_question_path) do %>
|
||||||
<main class="questions_tpl">
|
<main class="questions_tpl">
|
||||||
<h2 class="question-text"><%= @question.question %></h2>
|
<h2 class="question-text"><%= @question.question %></h2>
|
||||||
<%= render partial: @question.input_type %>
|
|
||||||
|
<div class="content-well">
|
||||||
|
<%= render partial: @question.input_type, locals: {question: @question, answer: @answer.answer } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% if @status.on_summary %>
|
<% if @status.on_summary %>
|
||||||
|
|
||||||
|
@ -1,2 +1,41 @@
|
|||||||
<h1>Candidate#summary</h1>
|
<main class="summary_tpl">
|
||||||
<p>Find me in app/views/candidate/summary.html.erb</p>
|
<h2 class="prft-heading">Almost done!</h2>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<%= form_tag(post_summary_path) do %>
|
||||||
|
<% @candidate.quiz.questions.each do |question| %>
|
||||||
|
<article class="answer-sec">
|
||||||
|
<div class="question-heading">
|
||||||
|
<div class="question-title">
|
||||||
|
<h3><%= question.question %></h3>
|
||||||
|
</div>
|
||||||
|
<div class="answer-buttons">
|
||||||
|
<a href="<%= question_path(question.to_i) %>" class="tertiary-btn button-edit" data-questionId="<%= question.to_i %>">Edit</a>
|
||||||
|
<button class="tertiary-btn button-save">Save</button>
|
||||||
|
<button class="tertiary-btn button-cancel">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="answer-container">
|
||||||
|
<fieldset disabled class="answer-block">
|
||||||
|
<%= render partial: question.input_type, locals: {question: question, answer: @answers.where(question_id: question.id).first.answer } %>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<% end #questions loop %>
|
||||||
|
|
||||||
|
<% if @status.can_submit %>
|
||||||
|
<div class="btn-container-right">
|
||||||
|
<input type="submit" class="submit-button" value="Submit all answers" name="submit" />
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="error">Sorry, you must answer all questions before you can submit.</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% end #form_tag %>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
@ -3,6 +3,7 @@ Rails.application.routes.draw do
|
|||||||
get "/thankyou", to: "candidate#thankyou", as: :thankyou
|
get "/thankyou", to: "candidate#thankyou", as: :thankyou
|
||||||
get "/saved", to: "candidate#saved", as: :saved
|
get "/saved", to: "candidate#saved", as: :saved
|
||||||
get "/summary", to: "candidate#summary", as: :summary
|
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
|
post "/question", to: "candidate#update_question", as: :post_question
|
||||||
get "/question", to: "candidate#question", as: :question
|
get "/question", to: "candidate#question", as: :question
|
||||||
post "/validate", to: "candidate#validate", as: :validate_candidate
|
post "/validate", to: "candidate#validate", as: :validate_candidate
|
||||||
|
Loading…
Reference in New Issue
Block a user