Browse Source

Experimental alteration of text for answers/questions

CLDC-1627-check-your-answers-page-changes
Mo Seedat 2 years ago
parent
commit
4ec4b7aab4
  1. 2
      app/models/form/page.rb
  2. 12
      app/models/form/question.rb
  3. 7
      app/models/form/sales/questions/buyer1_age_known.rb
  4. 6
      app/models/form/sales/questions/buyer2_age_known.rb
  5. 8
      db/schema.rb

2
app/models/form/page.rb

@ -8,7 +8,7 @@ class Form::Page
if hsh if hsh
@header = hsh["header"] @header = hsh["header"]
@description = hsh["description"] @description = hsh["description"]
@questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) } @questions = hsh["questions"].map { |q_id, q| puts "New FORM for q: #{q.inspect}"; Form::Question.new(q_id, q, self) }
@depends_on = hsh["depends_on"] @depends_on = hsh["depends_on"]
@title_text = hsh["title_text"] @title_text = hsh["title_text"]
@informative_text = hsh["informative_text"] @informative_text = hsh["informative_text"]

12
app/models/form/question.rb

@ -1,7 +1,7 @@
class Form::Question class Form::Question
attr_accessor :id, :header, :hint_text, :description, :questions, attr_accessor :id, :header, :hint_text, :description, :questions,
:type, :min, :max, :step, :width, :fields_to_add, :result_field, :type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label, :conditional_for, :readonly, :answer_options, :summary_labels, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived, :check_answers_card_number :guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived, :check_answers_card_number
@ -27,7 +27,8 @@ class Form::Question
@fields_to_add = hsh["fields-to-add"] @fields_to_add = hsh["fields-to-add"]
@result_field = hsh["result-field"] @result_field = hsh["result-field"]
@readonly = hsh["readonly"] @readonly = hsh["readonly"]
@answer_options = hsh["answer_options"] @answer_options = (hsh["answer_options"] || {}).merge(hsh["summary_labels"] || {})
@summary_labels = hsh["summary_labels"]
@conditional_for = hsh["conditional_for"] @conditional_for = hsh["conditional_for"]
@inferred_answers = hsh["inferred_answers"] @inferred_answers = hsh["inferred_answers"]
@inferred_check_answers_value = hsh["inferred_check_answers_value"] @inferred_check_answers_value = hsh["inferred_check_answers_value"]
@ -44,7 +45,9 @@ class Form::Question
delegate :subsection, to: :page delegate :subsection, to: :page
delegate :form, to: :subsection delegate :form, to: :subsection
# Used by Summary page
def answer_label(log) def answer_label(log)
puts "LOG: #{log.type}"
return checkbox_answer_label(log) if type == "checkbox" return checkbox_answer_label(log) if type == "checkbox"
return log[id]&.to_formatted_s(:govuk_date).to_s if type == "date" return log[id]&.to_formatted_s(:govuk_date).to_s if type == "date"
@ -255,6 +258,11 @@ class Form::Question
@guidance_partial && @guidance_position == GuidancePosition::BOTTOM @guidance_partial && @guidance_position == GuidancePosition::BOTTOM
end end
# Override display label when showing to a summary page
# def answer_options
# end
private private
def selected_answer_option_is_derived?(log) def selected_answer_option_is_derived?(log)

7
app/models/form/sales/questions/buyer1_age_known.rb

@ -6,6 +6,7 @@ class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question
@header = "Do you know buyer 1’s age?" @header = "Do you know buyer 1’s age?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@summary_labels = SUMMARY_LABELS
@page = page @page = page
@hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@conditional_for = { @conditional_for = {
@ -18,4 +19,10 @@ class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question
"1" => { "value" => "No" }, "1" => { "value" => "No" },
"2" => { "value" => "Buyer prefers not to say" }, "2" => { "value" => "Buyer prefers not to say" },
}.freeze }.freeze
SUMMARY_LABELS = {
"0" => { "value" => "Yes" },
"1" => { "value" => "Not known" },
"2" => { "value" => "Buyer prefers not to say" },
}.freeze
end end

6
app/models/form/sales/questions/buyer2_age_known.rb

@ -6,6 +6,7 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question
@header = "Do you know buyer 2’s age?" @header = "Do you know buyer 2’s age?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@summary_labels = SUMMARY_LABELS
@page = page @page = page
@conditional_for = { @conditional_for = {
"age2" => [0], "age2" => [0],
@ -16,4 +17,9 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question
"0" => { "value" => "Yes" }, "0" => { "value" => "Yes" },
"1" => { "value" => "No" }, "1" => { "value" => "No" },
}.freeze }.freeze
SUMMARY_LABELS = {
"0" => { "value" => "Yes" },
"1" => { "value" => "Not known" },
}.freeze
end end

8
db/schema.rb

@ -339,14 +339,14 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do
t.string "sex1" t.string "sex1"
t.integer "buy1livein" t.integer "buy1livein"
t.integer "buylivein" t.integer "buylivein"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "builtype" t.integer "builtype"
t.integer "proptype" t.integer "proptype"
t.string "relat2"
t.string "otherrelat2"
t.integer "age2" t.integer "age2"
t.integer "age2_known" t.integer "age2_known"
t.integer "ethnic" t.string "relat2"
t.integer "ethnic_group" t.string "otherrelat2"
t.string "sex2" t.string "sex2"
t.integer "noint" t.integer "noint"
t.integer "buy2livein" t.integer "buy2livein"

Loading…
Cancel
Save