Browse Source

add question_number method to question

CLDC-1864-question-numbering-too
Kat 2 years ago
parent
commit
9d3632b2e6
  1. 4
      app/helpers/question_view_helper.rb
  2. 4
      app/models/form/question.rb
  3. 4
      app/models/form/sales/questions/ownership_scheme.rb
  4. 4
      app/models/form/sales/questions/purchaser_code.rb
  5. 4
      app/models/form/sales/questions/sale_date.rb
  6. 4
      app/models/form/sales/questions/shared_ownership_type.rb
  7. 2
      app/views/form/_textarea_question.html.erb

4
app/helpers/question_view_helper.rb

@ -5,9 +5,9 @@ module QuestionViewHelper
{ text: caption_text.html_safe, size: "l" }
end
def legend(question, page_header, conditional)
def legend(question, page_header, conditional, log = nil)
{
text: question.header.html_safe,
text: [question.question_number(log), question.header.html_safe].compact.join(" - "),
size: label_size(page_header, conditional),
tag: label_tag(page_header, conditional),
}

4
app/models/form/question.rb

@ -258,6 +258,10 @@ class Form::Question
selected_answer_option_is_derived?(log) || has_inferred_check_answers_value?(log)
end
def question_number(log)
nil
end
private
def selected_answer_option_is_derived?(log)

4
app/models/form/sales/questions/ownership_scheme.rb

@ -13,4 +13,8 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question
"2" => { "value" => "Yes - a discounted ownership scheme" },
"3" => { "value" => "No - this is an outright or other sale" },
}.freeze
def question_number(log)
"Q3"
end
end

4
app/models/form/sales/questions/purchaser_code.rb

@ -8,4 +8,8 @@ class Form::Sales::Questions::PurchaserCode < ::Form::Question
@type = "text"
@width = 10
end
def question_number(log)
"Q2"
end
end

4
app/models/form/sales/questions/sale_date.rb

@ -6,4 +6,8 @@ class Form::Sales::Questions::SaleDate < ::Form::Question
@header = "What is the sale completion date?"
@type = "date"
end
def question_number(log)
"Q1"
end
end

4
app/models/form/sales/questions/shared_ownership_type.rb

@ -18,4 +18,8 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
"31" => { "value" => "Right to Shared Ownership" },
"30" => { "value" => "Shared Ownership - 2021 model lease" },
}.freeze
def question_number(log)
"Q4"
end
end

2
app/views/form/_textarea_question.html.erb

@ -2,7 +2,7 @@
<%= f.govuk_text_area question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
label: legend(question, page_header, conditional),
label: legend(question, page_header, conditional, @log),
hint: { text: question.hint_text&.html_safe },
width: question.width || nil,
**stimulus_html_attributes(question) %>

Loading…
Cancel
Save