diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index b34ab0740..f162f1f64 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -28,13 +28,13 @@ class CaseLogsController < ApplicationController answers_for_page = page_params(questions_for_page).select { |k, _v| questions_for_page.include?(k) } @case_log.update!(answers_for_page) next_page = form.next_page(previous_page) - redirect_path = if next_page == :check_answers + redirect_path = if next_page == :check_answers subsection = form.subsection_for_page(previous_page) "case_log_#{subsection}_check_answers_path" - else + else "case_log_#{next_page}_path" end - + redirect_to(send(redirect_path, @case_log)) end @@ -44,7 +44,7 @@ class CaseLogsController < ApplicationController current_url = request.env['PATH_INFO'] subsection = current_url.split('/')[-2] subsection_pages = form.pages_for_subsection(subsection) - render "form/check_answers", locals: { case_log_id: @case_log.id, case_log: @case_log, subsection_pages: subsection_pages } + render "form/check_answers", locals: { case_log: @case_log, subsection_pages: subsection_pages } end form = Form.new(2021, 2022) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 883105de9..464f42fab 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -13,8 +13,8 @@ module CheckAnswersHelper link_to(link_name, "/case_logs/#{case_log_id}/#{page}", class: "govuk-link").html_safe end - def create_next_missing_question_link(case_log_id, subsections, case_log) - empty_question = subsections.keys.find{|x| case_log[x].blank? } + def create_next_missing_question_link(case_log_id, subsection_pages, case_log) + empty_question = subsection_pages.keys.find{|x| case_log[x].blank? } url = "/case_logs/#{case_log_id}/#{empty_question}" link_to('Answer the missing questions', url, class: "govuk-link").html_safe diff --git a/app/views/form/_check_answers_table.html.erb b/app/views/form/_check_answers_table.html.erb new file mode 100644 index 000000000..b4551f622 --- /dev/null +++ b/app/views/form/_check_answers_table.html.erb @@ -0,0 +1,13 @@ +
You answered <%= get_answered_questions_total(subsection_pages, case_log) %> of <%= subsection_pages.count %> questions
- <%= create_next_missing_question_link(case_log_id, subsection_pages, case_log) %> + <%= create_next_missing_question_link(case_log["id"], subsection_pages, case_log) %> <% subsection_pages.each do |page, page_info| %> -