diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb
new file mode 100644
index 000000000..c2e3c8ee5
--- /dev/null
+++ b/app/components/check_answers_summary_list_card_component.html.erb
@@ -0,0 +1,37 @@
+
+ <% if applicable_questions.first.check_answers_card_number != 0 %>
+
+ <% end %>
+
+ <%= govuk_summary_list do |summary_list| %>
+ <% applicable_questions.each do |question| %>
+ <% summary_list.row do |row| %>
+ <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %>
+ <% row.value do %>
+ <%= get_answer_label(question) %>
+ <% extra_value = question.get_extra_check_answer_value(case_log) %>
+ <% if extra_value %>
+ <%= extra_value %>
+ <% end %>
+
+ <% question.get_inferred_answers(case_log).each do |inferred_answer| %>
+ <%= inferred_answer %>
+ <% end %>
+ <% end %>
+ <% row.action(
+ text: question.action_text(case_log),
+ href: question.action_href(case_log, question.page.id),
+ visually_hidden_text: question.check_answer_label.to_s.downcase,
+ ) %>
+ <% end %>
+ <% end %>
+ <% end %>
+
+
diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb
new file mode 100644
index 000000000..0ae6afcac
--- /dev/null
+++ b/app/components/check_answers_summary_list_card_component.rb
@@ -0,0 +1,18 @@
+class CheckAnswersSummaryListCardComponent < ViewComponent::Base
+ attr_reader :questions, :case_log, :user
+
+ def initialize(questions:, case_log:, user:)
+ @questions = questions
+ @case_log = case_log
+ @user = user
+ super
+ end
+
+ def applicable_questions
+ questions.reject { |q| q.hidden_in_check_answers?(case_log, user) }
+ end
+
+ def get_answer_label(question)
+ question.answer_label(case_log).presence || "You didn’t answer this question".html_safe
+ end
+end
diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb
index 760c08ab0..9c0401f79 100644
--- a/app/helpers/check_answers_helper.rb
+++ b/app/helpers/check_answers_helper.rb
@@ -24,6 +24,10 @@ module CheckAnswersHelper
end
end
+ def any_questions_have_summary_card_number?(subsection, case_log)
+ subsection.applicable_questions(case_log).map(&:check_answers_card_number).compact.length.positive?
+ end
+
private
def answered_questions_count(subsection, case_log, current_user)
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index c21477bc9..11fa40c0b 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -3,7 +3,7 @@ class Form::Question
:type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
- :guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived
+ :guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived, :check_answers_card_number
module GuidancePosition
TOP = 1
@@ -37,6 +37,7 @@ class Form::Question
@suffix = hsh["suffix"]
@requires_js = hsh["requires_js"]
@fields_added = hsh["fields_added"]
+ @check_answers_card_number = hsh["check_answers_card_number"]
end
end
diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb
index 8db15d81e..44b4f89d4 100644
--- a/app/views/form/check_answers.html.erb
+++ b/app/views/form/check_answers.html.erb
@@ -17,10 +17,16 @@
<% end %>
<%= display_answered_questions_summary(subsection, @case_log, current_user) %>
- <%= render partial: "form/check_answers_summary_list", locals: {
- subsection:,
- case_log: @case_log,
- } %>
+ <% if any_questions_have_summary_card_number?(subsection, @case_log) %>
+ <% subsection.applicable_questions(@case_log).group_by(&:check_answers_card_number).values.each do |question_group| %>
+ <%= render CheckAnswersSummaryListCardComponent.new(questions: question_group, case_log: @case_log, user: current_user) %>
+ <% end %>
+ <% else %>
+ <%= render partial: "form/check_answers_summary_list", locals: {
+ subsection:,
+ case_log: @case_log,
+ } %>
+ <% end %>
<%= form_with model: @case_log, method: "get" do |f| %>
<%= f.govuk_submit "Save and return to log" do %>
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index d365a5a8f..e2e0f0131 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -1127,6 +1127,7 @@
"header": "",
"guidance_partial": "privacy_notice",
"check_answer_label": "Tenant has seen the privacy notice",
+ "check_answers_card_number": 0,
"type": "checkbox",
"answer_options": {
"declaration": {
@@ -1141,6 +1142,7 @@
"description": "",
"questions": {
"hhmemb": {
+ "check_answers_card_number": 0,
"check_answer_label": "Number of household members",
"header": "How many people live in the household for this letting?",
"hint_text": "You can provide details for a maximum of 8 people.",
@@ -1240,6 +1242,7 @@
"description": "",
"questions": {
"age1_known": {
+ "check_answers_card_number": 1,
"header": "Do you know the lead tenant’s age?",
"hint_text": "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1266,6 +1269,7 @@
}
},
"age1": {
+ "check_answers_card_number": 1,
"header": "Age",
"check_answer_label": "Lead tenant’s age",
"type": "numeric",
@@ -1371,6 +1375,7 @@
"questions": {
"sex1": {
"check_answer_label": "Lead tenant’s gender identity",
+ "check_answers_card_number": 1,
"header": "Which of these best describes the lead tenant’s gender identity?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1483,6 +1488,7 @@
"questions": {
"ethnic_group": {
"check_answer_label": "Lead tenant’s ethnic group",
+ "check_answers_card_number": 1,
"header": "What is the lead tenant’s ethnic group?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1518,6 +1524,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Arab background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1539,6 +1546,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Asian or Asian British background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1569,6 +1577,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1593,6 +1602,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1620,6 +1630,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s White background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1647,6 +1658,7 @@
"description": "",
"questions": {
"national": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s nationality",
"header": "What is the lead tenant’s nationality?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1716,6 +1728,7 @@
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
+ "check_answers_card_number": 1,
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
"answer_options": {
@@ -1871,6 +1884,7 @@
"questions": {
"details_known_2": {
"check_answer_label": "Details known for person 2",
+ "check_answers_card_number": 2,
"header": "Do you know details for person 2?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -1914,6 +1928,7 @@
"questions": {
"relat2": {
"check_answer_label": "Person 2’s relationship to the lead tenant",
+ "check_answers_card_number": 2,
"header": "What is person 2’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -1949,6 +1964,7 @@
"questions": {
"age2_known": {
"header": "Do you know person 2’s age?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -1976,6 +1992,7 @@
"age2": {
"header": "Age",
"check_answer_label": "Person 2’s age",
+ "check_answers_card_number": 2,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2087,6 +2104,7 @@
"sex2": {
"check_answer_label": "Person 2’s gender identity",
"header": "Which of these best describes person 2’s gender identity?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2208,6 +2226,7 @@
"questions": {
"ecstat2": {
"check_answer_label": "Person 2’s working situation",
+ "check_answers_card_number": 2,
"header": "Which of these best describes person 2’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2383,6 +2402,7 @@
"questions": {
"details_known_3": {
"check_answer_label": "Details known for person 3",
+ "check_answers_card_number": 3,
"header": "Do you know details for person 3?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2423,6 +2443,7 @@
"questions": {
"relat3": {
"check_answer_label": "Person 3’s relationship to the lead tenant",
+ "check_answers_card_number": 3,
"header": "What is person 3’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2458,6 +2479,7 @@
"questions": {
"age3_known": {
"header": "Do you know person 3’s age?",
+ "check_answers_card_number": 3,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2485,6 +2507,7 @@
"age3": {
"header": "Age",
"check_answer_label": "Person 3’s age",
+ "check_answers_card_number": 3,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2595,6 +2618,7 @@
"questions": {
"sex3": {
"check_answer_label": "Person 3’s gender identity",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -2717,6 +2741,7 @@
"questions": {
"ecstat3": {
"check_answer_label": "Person 3’s working situation",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2892,6 +2917,7 @@
"questions": {
"details_known_4": {
"check_answer_label": "Details known for person 4",
+ "check_answers_card_number": 4,
"header": "Do you know details for person 4?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2929,6 +2955,7 @@
"questions": {
"relat4": {
"check_answer_label": "Person 4’s relationship to the lead tenant",
+ "check_answers_card_number": 4,
"header": "What is person 4’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2964,6 +2991,7 @@
"questions": {
"age4_known": {
"header": "Do you know person 4’s age?",
+ "check_answers_card_number": 4,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2991,6 +3019,7 @@
"age4": {
"header": "Age",
"check_answer_label": "Person 4’s age",
+ "check_answers_card_number": 4,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3101,6 +3130,7 @@
"questions": {
"sex4": {
"check_answer_label": "Person 4’s gender identity",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3223,6 +3253,7 @@
"questions": {
"ecstat4": {
"check_answer_label": "Person 4’s working situation",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3398,6 +3429,7 @@
"questions": {
"details_known_5": {
"check_answer_label": "Details known for person 5",
+ "check_answers_card_number": 5,
"header": "Do you know details for person 5?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3432,6 +3464,7 @@
"questions": {
"relat5": {
"check_answer_label": "Person 5’s relationship to the lead tenant",
+ "check_answers_card_number": 5,
"header": "What is person 5’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3467,6 +3500,7 @@
"questions": {
"age5_known": {
"header": "Do you know person 5’s age?",
+ "check_answers_card_number": 5,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3494,6 +3528,7 @@
"age5": {
"header": "Age",
"check_answer_label": "Person 5’s age",
+ "check_answers_card_number": 5,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3604,6 +3639,7 @@
"questions": {
"sex5": {
"check_answer_label": "Person 5’s gender identity",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3726,6 +3762,7 @@
"questions": {
"ecstat5": {
"check_answer_label": "Person 5’s working situation",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3901,6 +3938,7 @@
"questions": {
"details_known_6": {
"check_answer_label": "Details known for person 6",
+ "check_answers_card_number": 6,
"header": "Do you know details for person 6?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3932,6 +3970,7 @@
"questions": {
"relat6": {
"check_answer_label": "Person 6’s relationship to the lead tenant",
+ "check_answers_card_number": 6,
"header": "What is person 6’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3967,6 +4006,7 @@
"questions": {
"age6_known": {
"header": "Do you know person 6’s age?",
+ "check_answers_card_number": 6,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3994,6 +4034,7 @@
"age6": {
"header": "Age",
"check_answer_label": "Person 6’s age",
+ "check_answers_card_number": 6,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4104,6 +4145,7 @@
"questions": {
"sex6": {
"check_answer_label": "Person 6’s gender identity",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4226,6 +4268,7 @@
"questions": {
"ecstat6": {
"check_answer_label": "Person 6’s working situation",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4401,6 +4444,7 @@
"questions": {
"details_known_7": {
"check_answer_label": "Details known for person 7",
+ "check_answers_card_number": 7,
"header": "Do you know details for person 7?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4429,6 +4473,7 @@
"questions": {
"relat7": {
"check_answer_label": "Person 7’s relationship to the lead tenant",
+ "check_answers_card_number": 7,
"header": "What is person 7’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4464,6 +4509,7 @@
"questions": {
"age7_known": {
"header": "Do you know person 7’s age?",
+ "check_answers_card_number": 7,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4491,6 +4537,7 @@
"age7": {
"header": "Age",
"check_answer_label": "Person 7’s age",
+ "check_answers_card_number": 7,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4601,6 +4648,7 @@
"questions": {
"sex7": {
"check_answer_label": "Person 7’s gender identity",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4723,6 +4771,7 @@
"questions": {
"ecstat7": {
"check_answer_label": "Person 7’s working situation",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4898,6 +4947,7 @@
"questions": {
"details_known_8": {
"check_answer_label": "Details known for person 8",
+ "check_answers_card_number": 8,
"header": "Do you know details for person 8?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4923,6 +4973,7 @@
"questions": {
"relat8": {
"check_answer_label": "Person 8’s relationship to the lead tenant",
+ "check_answers_card_number": 8,
"header": "What is person 8’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4958,6 +5009,7 @@
"questions": {
"age8_known": {
"header": "Do you know person 8’s age?",
+ "check_answers_card_number": 8,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4985,6 +5037,7 @@
"age8": {
"header": "Age",
"check_answer_label": "Person 8’s age",
+ "check_answers_card_number": 8,
"type": "numeric",
"min": 0,
"max": 120,
@@ -5095,6 +5148,7 @@
"questions": {
"sex8": {
"check_answer_label": "Person 8’s gender identity",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -5217,6 +5271,7 @@
"questions": {
"ecstat8": {
"check_answer_label": "Person 8’s working situation",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s working situation?",
"hint_text": "",
"type": "radio",
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index 0e737c43e..0102d5587 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -1162,6 +1162,7 @@
"header": "",
"guidance_partial": "privacy_notice",
"check_answer_label": "Tenant has seen the privacy notice",
+ "check_answers_card_number": 0,
"type": "checkbox",
"answer_options": {
"declaration": {
@@ -1176,6 +1177,7 @@
"description": "",
"questions": {
"hhmemb": {
+ "check_answers_card_number": 0,
"check_answer_label": "Number of household members",
"header": "How many people live in the household for this letting?",
"hint_text": "You can provide details for a maximum of 8 people.",
@@ -1228,7 +1230,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1271,6 +1277,7 @@
"description": "",
"questions": {
"age1_known": {
+ "check_answers_card_number": 1,
"header": "Do you know the lead tenant’s age?",
"hint_text": "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1297,6 +1304,7 @@
}
},
"age1": {
+ "check_answers_card_number": 1,
"header": "Age",
"check_answer_label": "Lead tenant’s age",
"type": "numeric",
@@ -1354,7 +1362,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_age_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1398,6 +1410,7 @@
"questions": {
"sex1": {
"check_answer_label": "Lead tenant’s gender identity",
+ "check_answers_card_number": 1,
"header": "Which of these best describes the lead tenant’s gender identity?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1462,7 +1475,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1506,6 +1523,7 @@
"questions": {
"ethnic_group": {
"check_answer_label": "Lead tenant’s ethnic group",
+ "check_answers_card_number": 1,
"header": "What is the lead tenant’s ethnic group?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
@@ -1541,6 +1559,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Arab background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1562,6 +1581,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Asian or Asian British background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1592,6 +1612,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1616,6 +1637,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1643,6 +1665,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s White background?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1670,6 +1693,7 @@
"description": "",
"questions": {
"national": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s nationality",
"header": "What is the lead tenant’s nationality?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -1703,6 +1727,7 @@
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
+ "check_answers_card_number": 1,
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
"answer_options": {
@@ -1798,7 +1823,9 @@
}
},
"lead_tenant_over_retirement_value_check": {
- "depends_on": [{ "person_1_not_retired_over_soft_max_age?": true }],
+ "depends_on": [
+ { "person_1_not_retired_over_soft_max_age?": true }
+ ],
"title_text": {
"translation": "soft_validations.retirement.max.title",
"arguments": [
@@ -1856,6 +1883,7 @@
"questions": {
"details_known_2": {
"check_answer_label": "Details known for person 2",
+ "check_answers_card_number": 2,
"header": "Do you know details for person 2?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -1899,6 +1927,7 @@
"questions": {
"relat2": {
"check_answer_label": "Person 2’s relationship to the lead tenant",
+ "check_answers_card_number": 2,
"header": "What is person 2’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -1934,6 +1963,7 @@
"questions": {
"age2_known": {
"header": "Do you know person 2’s age?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -1961,6 +1991,7 @@
"age2": {
"header": "Age",
"check_answer_label": "Person 2’s age",
+ "check_answers_card_number": 2,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2072,6 +2103,7 @@
"sex2": {
"check_answer_label": "Person 2’s gender identity",
"header": "Which of these best describes person 2’s gender identity?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2193,6 +2225,7 @@
"questions": {
"ecstat2": {
"check_answer_label": "Person 2’s working situation",
+ "check_answers_card_number": 2,
"header": "Which of these best describes person 2’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2368,6 +2401,7 @@
"questions": {
"details_known_3": {
"check_answer_label": "Details known for person 3",
+ "check_answers_card_number": 3,
"header": "Do you know details for person 3?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2408,6 +2442,7 @@
"questions": {
"relat3": {
"check_answer_label": "Person 3’s relationship to the lead tenant",
+ "check_answers_card_number": 3,
"header": "What is person 3’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2443,6 +2478,7 @@
"questions": {
"age3_known": {
"header": "Do you know person 3’s age?",
+ "check_answers_card_number": 3,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2470,6 +2506,7 @@
"age3": {
"header": "Age",
"check_answer_label": "Person 3’s age",
+ "check_answers_card_number": 3,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2580,6 +2617,7 @@
"questions": {
"sex3": {
"check_answer_label": "Person 3’s gender identity",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -2702,6 +2740,7 @@
"questions": {
"ecstat3": {
"check_answer_label": "Person 3’s working situation",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2877,6 +2916,7 @@
"questions": {
"details_known_4": {
"check_answer_label": "Details known for person 4",
+ "check_answers_card_number": 4,
"header": "Do you know details for person 4?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2914,6 +2954,7 @@
"questions": {
"relat4": {
"check_answer_label": "Person 4’s relationship to the lead tenant",
+ "check_answers_card_number": 4,
"header": "What is person 4’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2949,6 +2990,7 @@
"questions": {
"age4_known": {
"header": "Do you know person 4’s age?",
+ "check_answers_card_number": 4,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2976,6 +3018,7 @@
"age4": {
"header": "Age",
"check_answer_label": "Person 4’s age",
+ "check_answers_card_number": 4,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3086,6 +3129,7 @@
"questions": {
"sex4": {
"check_answer_label": "Person 4’s gender identity",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3208,6 +3252,7 @@
"questions": {
"ecstat4": {
"check_answer_label": "Person 4’s working situation",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3383,6 +3428,7 @@
"questions": {
"details_known_5": {
"check_answer_label": "Details known for person 5",
+ "check_answers_card_number": 5,
"header": "Do you know details for person 5?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3417,6 +3463,7 @@
"questions": {
"relat5": {
"check_answer_label": "Person 5’s relationship to the lead tenant",
+ "check_answers_card_number": 5,
"header": "What is person 5’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3452,6 +3499,7 @@
"questions": {
"age5_known": {
"header": "Do you know person 5’s age?",
+ "check_answers_card_number": 5,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3479,6 +3527,7 @@
"age5": {
"header": "Age",
"check_answer_label": "Person 5’s age",
+ "check_answers_card_number": 5,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3589,6 +3638,7 @@
"questions": {
"sex5": {
"check_answer_label": "Person 5’s gender identity",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3711,6 +3761,7 @@
"questions": {
"ecstat5": {
"check_answer_label": "Person 5’s working situation",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3886,6 +3937,7 @@
"questions": {
"details_known_6": {
"check_answer_label": "Details known for person 6",
+ "check_answers_card_number": 6,
"header": "Do you know details for person 6?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3917,6 +3969,7 @@
"questions": {
"relat6": {
"check_answer_label": "Person 6’s relationship to the lead tenant",
+ "check_answers_card_number": 6,
"header": "What is person 6’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3952,6 +4005,7 @@
"questions": {
"age6_known": {
"header": "Do you know person 6’s age?",
+ "check_answers_card_number": 6,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3979,6 +4033,7 @@
"age6": {
"header": "Age",
"check_answer_label": "Person 6’s age",
+ "check_answers_card_number": 6,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4089,6 +4144,7 @@
"questions": {
"sex6": {
"check_answer_label": "Person 6’s gender identity",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4211,6 +4267,7 @@
"questions": {
"ecstat6": {
"check_answer_label": "Person 6’s working situation",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4386,6 +4443,7 @@
"questions": {
"details_known_7": {
"check_answer_label": "Details known for person 7",
+ "check_answers_card_number": 7,
"header": "Do you know details for person 7?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4414,6 +4472,7 @@
"questions": {
"relat7": {
"check_answer_label": "Person 7’s relationship to the lead tenant",
+ "check_answers_card_number": 7,
"header": "What is person 7’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4449,6 +4508,7 @@
"questions": {
"age7_known": {
"header": "Do you know person 7’s age?",
+ "check_answers_card_number": 7,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4476,6 +4536,7 @@
"age7": {
"header": "Age",
"check_answer_label": "Person 7’s age",
+ "check_answers_card_number": 7,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4586,6 +4647,7 @@
"questions": {
"sex7": {
"check_answer_label": "Person 7’s gender identity",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4708,6 +4770,7 @@
"questions": {
"ecstat7": {
"check_answer_label": "Person 7’s working situation",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4883,6 +4946,7 @@
"questions": {
"details_known_8": {
"check_answer_label": "Details known for person 8",
+ "check_answers_card_number": 8,
"header": "Do you know details for person 8?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4908,6 +4972,7 @@
"questions": {
"relat8": {
"check_answer_label": "Person 8’s relationship to the lead tenant",
+ "check_answers_card_number": 8,
"header": "What is person 8’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4943,6 +5008,7 @@
"questions": {
"age8_known": {
"header": "Do you know person 8’s age?",
+ "check_answers_card_number": 8,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4970,6 +5036,7 @@
"age8": {
"header": "Age",
"check_answer_label": "Person 8’s age",
+ "check_answers_card_number": 8,
"type": "numeric",
"min": 0,
"max": 120,
@@ -5080,6 +5147,7 @@
"questions": {
"sex8": {
"check_answer_label": "Person 8’s gender identity",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -5202,6 +5270,7 @@
"questions": {
"ecstat8": {
"check_answer_label": "Person 8’s working situation",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s working situation?",
"hint_text": "",
"type": "radio",
diff --git a/spec/components/check_answers_summary_list_card_component_spec.rb b/spec/components/check_answers_summary_list_card_component_spec.rb
new file mode 100644
index 000000000..9ccfebe51
--- /dev/null
+++ b/spec/components/check_answers_summary_list_card_component_spec.rb
@@ -0,0 +1,27 @@
+require "rails_helper"
+
+RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
+ context "when given a set of questions" do
+ let(:user) { FactoryBot.build(:user) }
+ let(:case_log) { FactoryBot.build(:case_log, :completed, age2: 99) }
+ let(:subsection_id) { "household_characteristics" }
+ let(:subsection) { case_log.form.get_subsection(subsection_id) }
+ let(:questions) { subsection.applicable_questions(case_log) }
+
+ it "renders a summary list card for the answers to those questions" do
+ result = render_inline(described_class.new(questions:, case_log:, user:))
+ expect(result).to have_content(questions.first.answer_label(case_log))
+ end
+
+ it "applicable questions doesn't return questions that are hidden in check answers" do
+ summary_list = described_class.new(questions:, case_log:, user:)
+ expect(summary_list.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false)
+ end
+
+ it "has the correct answer label for a question" do
+ summary_list = described_class.new(questions:, case_log:, user:)
+ sex1_question = questions[2]
+ expect(summary_list.get_answer_label(sex1_question)).to eq("Female")
+ end
+ end
+end
diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb
index 4e4253470..3ba4e28ab 100644
--- a/spec/features/form/check_answers_page_spec.rb
+++ b/spec/features/form/check_answers_page_spec.rb
@@ -133,6 +133,19 @@ RSpec.describe "Form Check Answers Page" do
end
end
+ it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
+ visit("/logs/#{completed_case_log.id}/household-needs/check-answers")
+ assert_selector ".x-govuk-summary-card__title", count: 0
+ end
+
+ context "when the user is checking their answers for the household characteristics subsection" do
+ it "they see a seperate summary card for each member of the household" do
+ visit("/logs/#{completed_case_log.id}/#{subsection}/check-answers")
+ assert_selector ".x-govuk-summary-card__title", text: "Lead tenant", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1
+ end
+ end
+
context "when viewing setup section answers" do
before do
FactoryBot.create(:location, scheme:)
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 9a24381e9..ea8b3ce40 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -13,6 +13,7 @@
"tenant_code_test": {
"questions": {
"tenancycode": {
+ "check_answers_card_number": 0,
"check_answer_label": "Tenant code",
"header": "What is the tenant code?",
"hint_text": "This is how you usually refer to this tenancy on your own systems.",
@@ -31,6 +32,7 @@
"person_1_age": {
"questions": {
"age1": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s age",
"header": "What is the tenant’s age?",
"type": "numeric",
@@ -52,6 +54,7 @@
"person_1_gender": {
"questions": {
"sex1": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s gender identity",
"header": "Which of these best describes the tenant’s gender identity?",
"type": "radio",
@@ -77,6 +80,7 @@
"description": "",
"questions": {
"ecstat1": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s socks?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
@@ -125,6 +129,7 @@
"household_number_of_members": {
"questions": {
"hhmemb": {
+ "check_answers_card_number": 0,
"check_answer_label": "Number of Household Members",
"header": "How many people are there in the household?",
"hint_text": "The maximum number of members is 8",
@@ -140,6 +145,7 @@
}
},
"relat2": {
+ "check_answers_card_number": 2,
"check_answer_label": "Person 2’s relationship to lead tenant",
"header": "What is person 2’s relationship to lead tenant",
"type": "radio",
@@ -153,6 +159,7 @@
}
},
"age2": {
+ "check_answers_card_number": 2,
"check_answer_label": "Person 2’s age",
"header": "Do you know person 2’s age?",
"type": "numeric",
@@ -162,6 +169,7 @@
"width": 2
},
"sex2": {
+ "check_answers_card_number": 2,
"check_answer_label": "Person 2’s gender identity",
"header": "Which of these best describes person 2’s gender identity?",
"type": "radio",
@@ -182,11 +190,35 @@
}
}
},
+ "retirement_value_check": {
+ "questions": {
+ "retirement_value_check": {
+ "check_answer_label": "Retirement age soft validation",
+ "hidden_in_check_answers": true,
+ "header": "Are you sure this person is retired?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ },
+ "depends_on": [
+ {
+ "age2": { "operator": ">", "operand": 50 }
+ }
+ ]
+ },
"person_2_working_situation": {
"header": "",
"description": "",
"questions": {
"ecstat2": {
+ "check_answers_card_number": 2,
"check_answer_label": "Person 2’s Work",
"header": "Which of these best describes person 2’s working situation?",
"type": "radio",
@@ -216,6 +248,7 @@
"propcode": {
"questions": {
"propcode": {
+ "check_answers_card_number": 0,
"check_answer_label": "",
"header": "property reference?",
"type": "text"
diff --git a/spec/models/form/subsection_spec.rb b/spec/models/form/subsection_spec.rb
index 1b876520a..95208b8e5 100644
--- a/spec/models/form/subsection_spec.rb
+++ b/spec/models/form/subsection_spec.rb
@@ -25,12 +25,12 @@ RSpec.describe Form::Subsection, type: :model do
end
it "has pages" do
- expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members person_2_working_situation propcode]
+ expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members retirement_value_check person_2_working_situation propcode]
expect(subsection.pages.map(&:id)).to eq(expected_pages)
end
it "has questions" do
- expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 ecstat2 propcode]
+ expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 retirement_value_check ecstat2 propcode]
expect(subsection.questions.map(&:id)).to eq(expected_questions)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 2222d737e..94a3af2fe 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe FormHandler do
form_handler = described_class.instance
form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(44)
+ expect(form.pages.count).to eq(45)
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index 291343cd9..4b6b66672 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -178,7 +178,7 @@ RSpec.describe Form, type: :model do
describe "invalidated_page_questions" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) }
- let(:expected_invalid) { %w[scheme_id condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] }
+ let(:expected_invalid) { %w[scheme_id retirement_value_check condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] }
context "when dependencies are not met" do
it "returns an array of question keys whose pages conditions are not met" do