moving post answer routes back
This commit is contained in:
parent
95eec915c4
commit
fff062a3a7
@ -21,6 +21,11 @@ class CandidateController < ApplicationController
|
||||
@answer = Answer.new
|
||||
end
|
||||
|
||||
def update_answer
|
||||
qid = prep_status.current_question_id
|
||||
send "process_#{prep_question(qid).input_type}"
|
||||
end
|
||||
|
||||
def live_coder
|
||||
question
|
||||
render layout: false
|
||||
@ -32,38 +37,6 @@ class CandidateController < ApplicationController
|
||||
redirect_to :question and return unless prep_status.current_question_id.nil?
|
||||
end
|
||||
|
||||
def update_text
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:text],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def update_radio
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:radio],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def update_checkbox
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:checkbox],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def update_live_code
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:live_code],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
# TODO
|
||||
def update_summary
|
||||
# redirect_to :summary
|
||||
@ -115,4 +88,36 @@ class CandidateController < ApplicationController
|
||||
redirect_to :question
|
||||
end
|
||||
end
|
||||
|
||||
def process_text
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:text],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def process_radio
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:radio],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def process_checkbox
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:checkbox],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
|
||||
def process_live_code
|
||||
@answer = prep_answer
|
||||
@answer.update(answer: answer_params[:live_code],
|
||||
saved: answer_params[:save],
|
||||
submitted: answer_params[:next])
|
||||
route_answer
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,6 @@
|
||||
<textarea data-id="code-js" name="code-js" class="code-answer code-js"><%= @answer['js'] unless @answer.nil? %></textarea>
|
||||
</div>
|
||||
|
||||
<%= render partial: "candidate/answer_errors", locals: {question: question, answer: @answer} %>
|
||||
<%= render partial: "candidate/answer_errors", locals: {question: @question, answer: @answer} %>
|
||||
|
||||
<div class="results" data-id="results"></div>
|
||||
|
@ -5,7 +5,7 @@
|
||||
content_for :footer_title, "Skills Assessment"
|
||||
%>
|
||||
|
||||
<%= form_for(@answer, url: send("post_#{@question.input_type}_path", @answer.id), html:{id: 'answer-form', data: {qid: @question.question_id}}) do |form| %>
|
||||
<%= form_for(@answer, url: post_answer_path(@answer.id), html:{id: 'answer-form', data: {qid: @question.question_id}}) do |form| %>
|
||||
<main class="questions_tpl">
|
||||
<h2 class="question-text"><%= @question.question %></h2>
|
||||
|
||||
|
@ -4,10 +4,7 @@ Rails.application.routes.draw do
|
||||
get "/thankyou", to: "candidate#thankyou", as: :thankyou
|
||||
get "/saved", to: "candidate#saved", as: :saved
|
||||
|
||||
post "/question/text(/:answer_id)", to: "candidate#update_text", as: :post_text
|
||||
post "/question/radio(/:answer_id)", to: "candidate#update_radio", as: :post_radio
|
||||
post "/question/checkbox(/:answer_id)", to: "candidate#update_checkbox", as: :post_checkbox
|
||||
post "/question/live-code(/:answer_id)", to: "candidate#update_live_code", as: :post_live_code
|
||||
post "/question(/:answer_id)", to: "candidate#update_answer", as: :post_answer
|
||||
get "/question(/:question_id)", to: "candidate#question", as: :question
|
||||
get "/live-coder-entry/:question_id", to: "candidate#live_coder", as: :live_coder
|
||||
|
||||
|
@ -53,7 +53,7 @@ class CandidateControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get flash message on bad radio response" do
|
||||
setup_auth candidates(:martha)
|
||||
qid = questions(:fed1).id
|
||||
post post_radio_url, params: { answer: { question_id: qid, radio: nil } }
|
||||
post post_answer_path, params: { answer: { question_id: qid, radio: nil } }
|
||||
|
||||
assert_response :success
|
||||
assert session[:test_id].present?
|
||||
|
Loading…
Reference in New Issue
Block a user