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
def next_question
@subsection = params[:subsection]
@case_log_id = params[:case_log_id]
result = if @subsection
FIRST_QUESTION_FOR_SUBSECTION[@subsection]
subsection = params[:subsection]
@case_log = CaseLog.find(params[:case_log_id])
result = if subsection
FIRST_QUESTION_FOR_SUBSECTION[subsection]
else
@previous_question = params[:previous_question]
NEXT_QUESTION[@previous_question]
previous_question = params[:previous_question]
answer = params[previous_question]
@case_log.update(previous_question => answer)
NEXT_QUESTION[previous_question]
end
render result, locals: { case_log_id: @case_log_id }
render result, locals: { case_log_id: @case_log.id }
end
end

Loading…
Cancel
Save