Submit summary
This commit is contained in:
@ -37,14 +37,13 @@ class CandidateController < ApplicationController
|
||||
redirect_to :question and return unless prep_status.current_question_id.nil?
|
||||
end
|
||||
|
||||
# TODO
|
||||
def update_summary
|
||||
# redirect_to :summary
|
||||
|
||||
# only after successful submission
|
||||
CandidateMailer.submitted(current_candidate).deliver_now
|
||||
RecruiterMailer.candidate_submitted(current_candidate).deliver_now
|
||||
ReviewerMailer.candidate_submission(current_candidate).deliver_now
|
||||
prep_status
|
||||
not_completed_error = 'You must complete all questions to submit your test.'
|
||||
record_error = 'There was a problem with your submission. Please try again later.'
|
||||
redirect_to :summary, flash: { error: not_completed_error } and return unless @status.can_submit
|
||||
redirect_to :thankyou and return if current_candidate.complete!
|
||||
redirect_to :summary, flash: { error: record_error }
|
||||
end
|
||||
|
||||
def validate
|
||||
|
@ -33,6 +33,17 @@ class Candidate < ApplicationRecord
|
||||
"--"
|
||||
end
|
||||
|
||||
def complete!
|
||||
if update_attributes(completed: true)
|
||||
CandidateMailer.submitted(self).deliver_now
|
||||
RecruiterMailer.candidate_submitted(self).deliver_now
|
||||
ReviewerMailer.candidate_submission(self).deliver_now
|
||||
return true
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def generate_test_hash
|
||||
|
@ -26,13 +26,13 @@
|
||||
</fieldset>
|
||||
</div>
|
||||
</article>
|
||||
<% end #questions loop %>
|
||||
<% end #form_tag %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @status.can_submit %>
|
||||
<div class="btn-container-right">
|
||||
<input type="submit" class="submit-button" value="Submit all answers" name="submit" />
|
||||
</div>
|
||||
<%= form_tag post_summary_path, class: "btn-container-right" do %>
|
||||
<input type="submit" class="submit-button" value="Submit all answers" name="submit" />
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="error">Sorry, you must answer all questions before you can submit.</div>
|
||||
<% end %>
|
||||
|
Reference in New Issue
Block a user