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%>