summary roughed in
This commit is contained in:
parent
f9930ce531
commit
3a1c7de698
@ -9,11 +9,19 @@ class CandidateController < ApplicationController
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
def summary
|
||||
@candidate = Candidate.where(test_hash: '6NjnourLE6Y').first
|
||||
@answers = @candidate.answers
|
||||
@status = QuizStatus.new(@candidate)
|
||||
end
|
||||
|
||||
def update_summary
|
||||
redirect_to :summary
|
||||
end
|
||||
|
||||
def thankyou
|
||||
@ -26,9 +34,9 @@ class CandidateController < ApplicationController
|
||||
redirect_to :question
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def question_params
|
||||
params.permit(:save)
|
||||
end
|
||||
# private
|
||||
#
|
||||
# def question_params
|
||||
# params.permit(:save)
|
||||
# end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
class Candidate < ApplicationRecord
|
||||
belongs_to :quiz
|
||||
has_many :questions, through: :quiz
|
||||
has_many :questions, -> { order("sort") }, through: :quiz
|
||||
has_many :answers
|
||||
belongs_to :recruiter, class_name: "User"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Quiz < ApplicationRecord
|
||||
has_many :questions
|
||||
has_many :questions, -> { order(:sort) }
|
||||
has_many :candidates
|
||||
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 %>
|
||||
|
||||
<%
|
||||
@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.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>
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer.</div>
|
||||
|
@ -21,17 +21,17 @@
|
||||
|
||||
<div class="code-input">
|
||||
<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 class="code-input">
|
||||
<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 class="code-input">
|
||||
<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>
|
||||
|
||||
-- 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 %>
|
||||
|
||||
<%
|
||||
@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.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>
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</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>
|
||||
<textarea id="textArea" name="textarea" rows="10"><%= @answer.answer %></textarea>
|
||||
<div class="chars">Characters remaining: <span></span></div>
|
||||
|
||||
<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>
|
||||
|
||||
</div>
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||
|
@ -8,7 +8,10 @@
|
||||
<%= form_tag(post_question_path) do %>
|
||||
<main class="questions_tpl">
|
||||
<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 %>
|
||||
|
||||
|
@ -1,2 +1,41 @@
|
||||
<h1>Candidate#summary</h1>
|
||||
<p>Find me in app/views/candidate/summary.html.erb</p>
|
||||
<main class="summary_tpl">
|
||||
<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 "/saved", to: "candidate#saved", as: :saved
|
||||
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
|
||||
get "/question", to: "candidate#question", as: :question
|
||||
post "/validate", to: "candidate#validate", as: :validate_candidate
|
||||
|
Loading…
Reference in New Issue
Block a user