Browse Source

Save answers as we submit

pull/21/head
baarkerlounger 3 years ago
parent
commit
f6fdd64bdd
  1. 16
      app/controllers/case_logs_controller.rb

16
app/controllers/case_logs_controller.rb

@ -31,14 +31,16 @@ class CaseLogsController < ApplicationController
}.freeze }.freeze
def next_question def next_question
@subsection = params[:subsection] subsection = params[:subsection]
@case_log_id = params[:case_log_id] @case_log = CaseLog.find(params[:case_log_id])
result = if @subsection result = if subsection
FIRST_QUESTION_FOR_SUBSECTION[@subsection] FIRST_QUESTION_FOR_SUBSECTION[subsection]
else else
@previous_question = params[:previous_question] previous_question = params[:previous_question]
NEXT_QUESTION[@previous_question] answer = params[previous_question]
@case_log.update(previous_question => answer)
NEXT_QUESTION[previous_question]
end end
render result, locals: { case_log_id: @case_log_id } render result, locals: { case_log_id: @case_log.id }
end end
end end

Loading…
Cancel
Save