Skip to content

Commit

Permalink
Merge pull request #3132 from DFE-Digital/LUPEYALPHA-946/update-error…
Browse files Browse the repository at this point in the history
…-messages-in-provider-journey

Update error message copy
  • Loading branch information
rjlynch authored Sep 2, 2024
2 parents f3be422 + d51e061 commit 14d1c55
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class VerifyClaimForm < Form

attribute :declaration, :boolean

validates :declaration, acceptance: true
validates :declaration, acceptance: {
message: i18n_error_message("declaration.acceptance")
}

validate :all_assertions_answered

Expand Down Expand Up @@ -61,9 +63,21 @@ def course_descriptions
@course_descriptions ||= claim.eligibility.courses_taught.map(&:description)
end

def teaching_hours_per_week
I18n.t(
[
"further_education_payments",
"forms",
"teaching_hours_per_week",
"options",
claim.eligibility.teaching_hours_per_week
].join(".")
).downcase
end

def assertions
@assertions ||= ASSERTIONS.fetch(contract_type).map do |assertion_name|
AssertionForm.new(name: assertion_name)
AssertionForm.new(name: assertion_name, parent_form: self)
end
end

Expand Down Expand Up @@ -116,7 +130,7 @@ def all_assertions_answered
assertion.errors.each do |error|
errors.add(
"assertions_attributes[#{i}][#{error.attribute}]",
error.full_message
error.message
)
end
end
Expand All @@ -132,15 +146,39 @@ class AssertionForm
include ActiveModel::Model
include ActiveModel::Attributes

attr_reader :parent_form

attribute :name, :string
attribute :outcome, :boolean

validates :name, presence: true
validates :outcome, inclusion: {
in: [true, false],
message: "Select an option"
message: ->(form, _) do
I18n.t(
[
"further_education_payments_provider",
"forms",
"verify_claim",
"assertions",
form.contract_type,
form.name,
"errors",
"inclusion"
].join("."),
claimant: form.claimant,
provider: form.provider,
hours: form.hours
)
end
}

def initialize(name:, parent_form:)
@parent_form = parent_form

super(name: name)
end

def radio_options
[
RadioOption.new(id: true, name: "Yes"),
Expand All @@ -149,6 +187,22 @@ def radio_options
end

class RadioOption < Struct.new(:id, :name, keyword_init: true); end

def claimant
parent_form.claim.first_name
end

def provider
parent_form.claim.school.name
end

def hours
parent_form.teaching_hours_per_week
end

def contract_type
parent_form.contract_type
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@
legend: {
size: "s",
text: f.object.t(
[:assertions, f.object.contract_type, ff.object.name],
[:assertions, f.object.contract_type, ff.object.name, :label],
claimant: f.object.claimant_name,
provider: f.object.claim.school.name,
hours: f.object.teaching_hours_per_week
),
},
hint: -> do
Expand Down
73 changes: 59 additions & 14 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1116,23 +1116,68 @@ en:
claimant_date_of_birth: "Claimant date of birth"
claimant_trn: "Claimant teacher reference number (TRN)"
claim_date: "Claim date"
errors:
declaration:
acceptance: "Tick the box to confirm that the information provided in this form is correct to the best of your knowledge"
assertions:
fixed_contract:
contract_type: "Does %{claimant} have a permanent contract of employment at %{provider}?"
teaching_responsibilities: "Is %{claimant} a member of staff with teaching responsibilities?"
further_education_teaching_start_year: "Is %{claimant} in the first 5 years of their further education teaching career in England?"
teaching_hours_per_week: "Is %{claimant} timetabled to teach an average of 12 hours per week during the current term?"
hours_teaching_eligible_subjects: "For at least half of their timetabled teaching hours, does %{claimant} teach 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?"
subjects_taught: "For at least half of their timetabled teaching hours, does %{claimant} teach:"
contract_type:
label: "Does %{claimant} have a permanent contract of employment at %{provider}?"
errors:
inclusion: "Select yes if %{claimant} has a fixed term contract of employment at %{provider}"
teaching_responsibilities:
label: "Is %{claimant} a member of staff with teaching responsibilities?"
errors:
inclusion: "Select yes if %{claimant} is a member of staff with teaching responsibilities"
further_education_teaching_start_year:
label: "Is %{claimant} in the first 5 years of their further education teaching career in England?"
errors:
inclusion: "Select yes if %{claimant} is in the first 5 years of their further education teaching career in England"
teaching_hours_per_week:
label: "Is %{claimant} timetabled to teach an average of %{hours} during the current term?"
errors:
inclusion: "Select yes if %{claimant} is timetabled to teach an average of %{hours} during the current term"
hours_teaching_eligible_subjects:
label: "For at least half of their timetabled teaching hours, does %{claimant} teach 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?"
errors:
inclusion: "Select yes if %{claimant} teaches 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP), for at least half of their timetabled teaching hours"
subjects_taught:
label: "For at least half of their timetabled teaching hours, does %{claimant} teach:"
errors:
inclusion: "Select yes if %{claimant} teaches this course for at least half their timetabled teaching hours"
variable_contract:
contract_type: "Does %{claimant} have a variable hour contract of employment at %{provider}?"
teaching_responsibilities: "Is %{claimant} a member of staff with teaching responsibilities?"
further_education_teaching_start_year: "Is %{claimant} in the first 5 years of their further education teaching career in England?"
taught_at_least_one_term: "Has %{claimant} taught for at least one academic term at %{provider}?"
teaching_hours_per_week: "Is %{claimant} timetabled to teach an average of 12 hours per week during the current term?"
hours_teaching_eligible_subjects: "For at least half of their timetabled teaching hours, does %{claimant} teach 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?"
subjects_taught: "For at least half of their timetabled teaching hours, does %{claimant} teach:"
teaching_hours_per_week_next_term: "Will %{claimant} be timetabled to teach at least 2.5 hours per week next term?"
contract_type:
label: "Does %{claimant} have a variable hour contract of employment at %{provider}?"
errors:
inclusion: "Select yes if %{claimant} has a variable hours contract of employment at %{provider}"
teaching_responsibilities:
label: "Is %{claimant} a member of staff with teaching responsibilities?"
errors:
inclusion: "Select yes if %{claimant} is a member of staff with teaching responsibilities"
further_education_teaching_start_year:
label: "Is %{claimant} in the first 5 years of their further education teaching career in England?"
errors:
inclusion: "Select yes if %{claimant} is in the first 5 years of their further education teaching career in England"
taught_at_least_one_term:
label: "Has %{claimant} taught for at least one academic term at %{provider}?"
errors:
inclusion: "Select yes if %{claimant} has taught at least one academic term at %{provider}"
teaching_hours_per_week:
label: "Is %{claimant} timetabled to teach an average of %{hours} during the current term?"
errors:
inclusion: "Select yes if %{claimant} is timetabled to teach an average of %{hours} during the current term"
hours_teaching_eligible_subjects:
label: "For at least half of their timetabled teaching hours, does %{claimant} teach 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?"
errors:
inclusion: "Select yes if %{claimant} teaches 16- to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP), for at least half of their timetabled teaching hours"
subjects_taught:
label: "For at least half of their timetabled teaching hours, does %{claimant} teach:"
errors:
inclusion: "Select yes if %{claimant} teaches this course for at least half their timetabled teaching hours"
teaching_hours_per_week_next_term:
label: "Will %{claimant} be timetabled to teach at least 2.5 hours per week next term?"
errors:
inclusion: "Select yes if %{claimant} will be timetabled to teach at least 2.5 hours per week next term"

early_years_payment:
claim_description: for an early years financial incentive payment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@
create(
:further_education_payments_eligibility,
claim: claim_1,
school: fe_provider
school: fe_provider,
teaching_hours_per_week: "more_than_12"
)

claim_2 = create(
Expand All @@ -284,7 +285,8 @@
create(
:further_education_payments_eligibility,
claim: claim_2,
school: fe_provider
school: fe_provider,
teaching_hours_per_week: "more_than_12"
)

mock_dfe_sign_in_auth_session(
Expand Down Expand Up @@ -395,6 +397,7 @@
:further_education_payments_eligibility,
claim: claim,
school: fe_provider,
teaching_hours_per_week: "more_than_12",
contract_type: "fixed_term",
subjects_taught: ["engineering_manufacturing"],
engineering_manufacturing_courses: [
Expand Down Expand Up @@ -461,8 +464,8 @@
end

within_fieldset(
"Is Edna Krabappel timetabled to teach an average of 12 hours per " \
"week during the current term?"
"Is Edna Krabappel timetabled to teach an average of more than 12 " \
"hours per week during the current term?"
) do
choose "Yes"
end
Expand Down Expand Up @@ -518,6 +521,7 @@
claim: claim,
school: fe_provider,
contract_type: "variable_hours",
teaching_hours_per_week: "between_2_5_and_12",
subjects_taught: ["engineering_manufacturing"],
engineering_manufacturing_courses: [
"approved_level_321_transportation",
Expand Down Expand Up @@ -590,8 +594,8 @@
end

within_fieldset(
"Is Edna Krabappel timetabled to teach an average of 12 hours per " \
"week during the current term?"
"Is Edna Krabappel timetabled to teach an average of between 2.5 and " \
"12 hours per week during the current term?"
) do
choose "Yes"
end
Expand Down
Loading

0 comments on commit 14d1c55

Please sign in to comment.