diff --git a/app/models/form.rb b/app/models/form.rb index ea803e5b6..3eeac8987 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -90,4 +90,21 @@ class Form pages_for_subsection(subsection).keys[current_page_idx - 1] end + + def all_questions + @all_questions ||= all_pages.map { |_page_key, page_value| + page_value["questions"] + }.reduce(:merge) + end + + def get_answer_label(case_log, question_title) + question = all_questions[question_title] + if question["type"] == "checkbox" + answer = [] + question["answer_options"].each { |key, value| case_log[key] == "Yes" ? answer << value : nil } + return answer.join(", ") + end + + case_log[question_title] + end end diff --git a/app/views/form/_check_answers_table.html.erb b/app/views/form/_check_answers_table.html.erb index 9025cf42d..eaa54075a 100644 --- a/app/views/form/_check_answers_table.html.erb +++ b/app/views/form/_check_answers_table.html.erb @@ -4,7 +4,7 @@ <%= question_info["check_answer_label"].to_s.present? ? question_info["check_answer_label"].to_s : question_info["header"].to_s%>
- <%= @case_log[question_title] %> + <%= form.get_answer_label(@case_log, question_title) %>
<%= create_update_answer_link(@case_log[question_title], @case_log.id, page)%> diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index f5b0fe93e..49ebeda0f 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -6,7 +6,7 @@ <% form.pages_for_subsection(subsection).each do |page, page_info| %> <% page_info["questions"].each do |question_title, question_info| %> <% if total_questions(subsection, @case_log, form).include?(question_title) %> - <%= render partial: 'form/check_answers_table', locals: { question_title: question_title, question_info: question_info, case_log: @case_log, page: page } %> + <%= render partial: 'form/check_answers_table', locals: { question_title: question_title, question_info: question_info, case_log: @case_log, page: page, form: form } %> <%end %> <%end %> <% end %>