From 2a21f92800a768f24405e3d417ffdf7ee71ffb11 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Tue, 9 Jul 2024 10:08:17 +0100 Subject: [PATCH] WIP --- app/forms/form.rb | 4 +- .../building_construction_courses_form.rb | 23 ++--- .../chemistry_courses_form.rb | 13 +-- .../computing_courses_form.rb | 32 ++----- .../early_years_courses_form.rb | 18 ++-- .../engineering_manufacturing_courses_form.rb | 33 ++----- .../hours_teaching_eligible_subjects_form.rb | 43 +++++++++ .../maths_courses_form.rb | 17 +--- .../physics_courses_form.rb | 13 +-- .../subjects_taught_form.rb | 12 +-- .../journeys/further_education_payments.rb | 3 +- .../courses_helper.rb | 92 +++++++++++++++++++ .../session_answers.rb | 5 + .../slug_sequence.rb | 2 +- .../hours_teaching_eligible_subjects.html.erb | 21 +++++ .../claims/teaching_courses.html.erb | 7 -- config/locales/en.yml | 26 +++--- .../happy_js_path_spec.rb | 4 +- .../happy_path_spec.rb | 10 +- spec/forms/form_spec.rb | 25 +++++ ...rs_teaching_eligible_subjects_form_spec.rb | 58 ++++++++++++ 21 files changed, 325 insertions(+), 136 deletions(-) create mode 100644 app/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form.rb create mode 100644 app/models/journeys/further_education_payments/courses_helper.rb create mode 100644 app/views/further_education_payments/claims/hours_teaching_eligible_subjects.html.erb delete mode 100644 app/views/further_education_payments/claims/teaching_courses.html.erb create mode 100644 spec/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form_spec.rb diff --git a/app/forms/form.rb b/app/forms/form.rb index 7c58c945b7..fa8ba1df41 100644 --- a/app/forms/form.rb +++ b/app/forms/form.rb @@ -39,7 +39,9 @@ def i18n_errors_path(msg, args = {}) end def t(key, args = {}) - I18n.t(key, scope: "#{i18n_namespace}.forms.#{i18n_form_namespace}", **args) + i18n_form_namespace_dup = args.delete(:i18n_form_namespace) || i18n_form_namespace + + I18n.t(key, scope: "#{i18n_namespace}.forms.#{i18n_form_namespace_dup}", **args) end def permitted_params diff --git a/app/forms/journeys/further_education_payments/building_construction_courses_form.rb b/app/forms/journeys/further_education_payments/building_construction_courses_form.rb index 7f8958e78f..86dbde462f 100644 --- a/app/forms/journeys/further_education_payments/building_construction_courses_form.rb +++ b/app/forms/journeys/further_education_payments/building_construction_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class BuildingConstructionCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :building_construction_courses, default: [] @@ -23,33 +20,27 @@ def checkbox_options [ OpenStruct.new( id: "esfa_buildingconstruction", - name: t( - "options.esfa_buildingconstruction", - link: govuk_link_to("building and construction", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=7", new_tab: true) - ) + name: course_option_description("esfa_buildingconstruction") ), OpenStruct.new( id: "tlevel_building", - name: t("options.tlevel_building") + name: course_option_description("tlevel_building") ), OpenStruct.new( id: "tlevel_onsiteconstruction", - name: t("options.tlevel_onsiteconstruction") + name: course_option_description("tlevel_onsiteconstruction") ), OpenStruct.new( id: "tlevel_design_surveying", - name: t("options.tlevel_design_surveying") + name: course_option_description("tlevel_design_surveying") ), OpenStruct.new( id: "level2_3_apprenticeship", - name: t( - "options.level2_3_apprenticeship", - link: govuk_link_to("construction and the built environment occupational route", "https://occupational-maps.instituteforapprenticeships.org/maps/route/construction", new_tab: true) - ) + name: course_option_description("level2_3_apprenticeship") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/chemistry_courses_form.rb b/app/forms/journeys/further_education_payments/chemistry_courses_form.rb index d4f1634062..0a17433c4e 100644 --- a/app/forms/journeys/further_education_payments/chemistry_courses_form.rb +++ b/app/forms/journeys/further_education_payments/chemistry_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class ChemistryCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :chemistry_courses, default: [] @@ -23,19 +20,19 @@ def checkbox_options [ OpenStruct.new( id: "alevel_chemistry", - name: t("options.alevel_chemistry") + name: course_option_description("alevel_chemistry") ), OpenStruct.new( id: "gcse_chemistry", - name: t("options.gcse_chemistry") + name: course_option_description("gcse_chemistry") ), OpenStruct.new( id: "ib_certificate_chemistry", - name: t("options.ib_certificate_chemistry") + name: course_option_description("ib_certificate_chemistry") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/computing_courses_form.rb b/app/forms/journeys/further_education_payments/computing_courses_form.rb index a50a0ab313..2a973e0840 100644 --- a/app/forms/journeys/further_education_payments/computing_courses_form.rb +++ b/app/forms/journeys/further_education_payments/computing_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class ComputingCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :computing_courses, default: [] @@ -23,48 +20,39 @@ def checkbox_options [ OpenStruct.new( id: "esfa_digitalpractitioners", - name: t( - "options.esfa_digitalpractitioners", - link: govuk_link_to("digital technology for practitioners", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=23&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa_digitalpractitioners") ), OpenStruct.new( id: "esfa_digitalusers", - name: t( - "options.esfa_digitalusers", - link: govuk_link_to("digital technology for users", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=22&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa_digitalusers") ), OpenStruct.new( id: "digitalskills_quals", - name: t("options.digitalskills_quals") + name: course_option_description("digitalskills_quals") ), OpenStruct.new( id: "tlevel_digitalsupport", - name: t("options.tlevel_digitalsupport") + name: course_option_description("tlevel_digitalsupport") ), OpenStruct.new( id: "tlevel_digitalbusiness", - name: t("options.tlevel_digitalbusiness") + name: course_option_description("tlevel_digitalbusiness") ), OpenStruct.new( id: "tlevel_digitalproduction", - name: t("options.tlevel_digitalproduction") + name: course_option_description("tlevel_digitalproduction") ), OpenStruct.new( id: "ib_certificate_compsci", - name: t("options.ib_certificate_compsci") + name: course_option_description("ib_certificate_compsci") ), OpenStruct.new( id: "level2_3_apprenticeship", - name: t( - "options.level2_3_apprenticeship", - link: govuk_link_to("digital occupational route", "https://occupational-maps.instituteforapprenticeships.org/maps/route/digital", new_tab: true) - ) + name: course_option_description("level2_3_apprenticeship") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/early_years_courses_form.rb b/app/forms/journeys/further_education_payments/early_years_courses_form.rb index 98a6bcf331..b4eb06da2b 100644 --- a/app/forms/journeys/further_education_payments/early_years_courses_form.rb +++ b/app/forms/journeys/further_education_payments/early_years_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class EarlyYearsCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :early_years_courses, default: [] @@ -23,26 +20,23 @@ def checkbox_options [ OpenStruct.new( id: "eylevel2", - name: t("options.eylevel2") + name: course_option_description("eylevel2") ), OpenStruct.new( id: "eylevel3", - name: t("options.eylevel3") + name: course_option_description("eylevel3") ), OpenStruct.new( id: "eytlevel", - name: t("options.eytlevel") + name: course_option_description("eytlevel") ), OpenStruct.new( id: "coursetoeyq", - name: t( - "options.coursetoeyq", - link: govuk_link_to("early years qualification", "https://www.gov.uk/government/publications/early-years-qualifications-achieved-in-england", new_tab: true) - ) + name: course_option_description("coursetoeyq") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/engineering_manufacturing_courses_form.rb b/app/forms/journeys/further_education_payments/engineering_manufacturing_courses_form.rb index a14e8e8759..f9a4fb1440 100644 --- a/app/forms/journeys/further_education_payments/engineering_manufacturing_courses_form.rb +++ b/app/forms/journeys/further_education_payments/engineering_manufacturing_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class EngineeringManufacturingCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :engineering_manufacturing_courses, default: [] @@ -23,47 +20,35 @@ def checkbox_options [ OpenStruct.new( id: "esfa_engineering", - name: t( - "options.esfa_engineering", - link: govuk_link_to("engineering", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=13&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa_engineering") ), OpenStruct.new( id: "esfa_manufacturing", - name: t( - "options.esfa_manufacturing", - link: govuk_link_to("manufacturing technologies", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=26&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa_manufacturing") ), OpenStruct.new( id: "esfa_transportation", - name: t( - "options.esfa_transportation", - link: govuk_link_to("transportation operations and maintenance", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=47&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa_transportation") ), OpenStruct.new( id: "tlevel_design", - name: t("options.tlevel_design") + name: course_option_description("tlevel_design") ), OpenStruct.new( id: "tlevel_maintenance", - name: t("options.tlevel_maintenance") + name: course_option_description("tlevel_maintenance") ), OpenStruct.new( id: "tlevel_engineering", - name: t("options.tlevel_engineering") + name: course_option_description("tlevel_engineering") ), OpenStruct.new( id: "level2_3_apprenticeship", - name: t( - "options.level2_3_apprenticeship", - link: govuk_link_to("engineering and manufacturing occupational route", "https://occupational-maps.instituteforapprenticeships.org/maps/route/engineering-manufacturing", new_tab: true) - ) + name: course_option_description("level2_3_apprenticeship") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form.rb b/app/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form.rb new file mode 100644 index 0000000000..15090e3774 --- /dev/null +++ b/app/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form.rb @@ -0,0 +1,43 @@ +module Journeys + module FurtherEducationPayments + class HoursTeachingEligibleSubjectsForm < Form + include CoursesHelper + + attribute :hours_teaching_eligible_subjects, :boolean + + validates :hours_teaching_eligible_subjects, + inclusion: { + in: [true, false], + message: i18n_error_message(:inclusion) + } + + def radio_options + [ + OpenStruct.new(id: true, name: "Yes"), + OpenStruct.new(id: false, name: "No") + ] + end + + def courses + ALL_COURSE_FIELDS.map { |course_field| + course_descriptions(course_field) + }.flatten + end + + def save + return false unless valid? + + journey_session.answers.assign_attributes(hours_teaching_eligible_subjects:) + journey_session.save! + end + + private + + def course_descriptions(course_field) + journey_session.answers.send(course_field).map { |course| + course_option_description(course, i18n_form_namespace: course_field).html_safe + } + end + end + end +end diff --git a/app/forms/journeys/further_education_payments/maths_courses_form.rb b/app/forms/journeys/further_education_payments/maths_courses_form.rb index b37505af57..a81b33cef1 100644 --- a/app/forms/journeys/further_education_payments/maths_courses_form.rb +++ b/app/forms/journeys/further_education_payments/maths_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class MathsCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :maths_courses, default: [] @@ -23,21 +20,15 @@ def checkbox_options [ OpenStruct.new( id: "esfa", - name: t( - "options.esfa", - link: govuk_link_to("mathematics and statistics", "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=28&PageSize=10&Sort=Status", new_tab: true) - ) + name: course_option_description("esfa") ), OpenStruct.new( id: "gcse_maths", - name: t( - "options.gcse_maths", - link: govuk_link_to("other maths qualifications", "https://submit-learner-data.service.gov.uk/find-a-learning-aim/LearningAimSearchResult?TeachingYear=2324&HasFilters=False&EFAFundingConditions=EFACONFUNDMATHS", new_tab: true) - ) + name: course_option_description("gcse_maths") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/physics_courses_form.rb b/app/forms/journeys/further_education_payments/physics_courses_form.rb index 93285e710a..0a543baa3d 100644 --- a/app/forms/journeys/further_education_payments/physics_courses_form.rb +++ b/app/forms/journeys/further_education_payments/physics_courses_form.rb @@ -2,10 +2,7 @@ module Journeys module FurtherEducationPayments class PhysicsCoursesForm < Form include ActiveModel::Validations::Callbacks - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::OutputSafetyHelper - include GovukVisuallyHiddenHelper - include GovukLinkHelper + include CoursesHelper attribute :physics_courses, default: [] @@ -23,19 +20,19 @@ def checkbox_options [ OpenStruct.new( id: "alevel_physics", - name: t("options.alevel_physics") + name: course_option_description("alevel_physics") ), OpenStruct.new( id: "gcse_physics", - name: t("options.gcse_physics") + name: course_option_description("gcse_physics") ), OpenStruct.new( id: "ib_certificate_physics", - name: t("options.ib_certificate_physics") + name: course_option_description("ib_certificate_physics") ), OpenStruct.new( id: "none", - name: t("options.none") + name: course_option_description("none") ) ] end diff --git a/app/forms/journeys/further_education_payments/subjects_taught_form.rb b/app/forms/journeys/further_education_payments/subjects_taught_form.rb index cfac6266b9..59c46205f1 100644 --- a/app/forms/journeys/further_education_payments/subjects_taught_form.rb +++ b/app/forms/journeys/further_education_payments/subjects_taught_form.rb @@ -2,6 +2,7 @@ module Journeys module FurtherEducationPayments class SubjectsTaughtForm < Form include ActiveModel::Validations::Callbacks + include CoursesHelper attribute :subjects_taught, default: [] @@ -12,16 +13,7 @@ class SubjectsTaughtForm < Form inclusion: {in: ->(form) { form.checkbox_options.map(&:id) }, message: i18n_error_message(:inclusion)} def checkbox_options - [ - OpenStruct.new(id: "building_construction", name: t("options.building_construction")), - OpenStruct.new(id: "chemistry", name: t("options.chemistry")), - OpenStruct.new(id: "computing", name: t("options.computing")), - OpenStruct.new(id: "early_years", name: t("options.early_years")), - OpenStruct.new(id: "engineering_manufacturing", name: t("options.engineering_manufacturing")), - OpenStruct.new(id: "maths", name: t("options.maths")), - OpenStruct.new(id: "physics", name: t("options.physics")), - OpenStruct.new(id: "none", name: t("options.none")) - ] + (ALL_SUBJECTS + ["none"]).map { |subject| OpenStruct.new(id: subject, name: t("options.#{subject}")) } end def save diff --git a/app/models/journeys/further_education_payments.rb b/app/models/journeys/further_education_payments.rb index d8ab668c6b..b1293539ae 100644 --- a/app/models/journeys/further_education_payments.rb +++ b/app/models/journeys/further_education_payments.rb @@ -27,7 +27,8 @@ module FurtherEducationPayments "poor-performance" => PoorPerformanceForm, "check-your-answers" => CheckYourAnswersForm, "ineligible" => IneligibleForm, - "half-teaching-hours" => HalfTeachingHoursForm + "half-teaching-hours" => HalfTeachingHoursForm, + "hours-teaching-eligible-subjects" => HoursTeachingEligibleSubjectsForm } } end diff --git a/app/models/journeys/further_education_payments/courses_helper.rb b/app/models/journeys/further_education_payments/courses_helper.rb new file mode 100644 index 0000000000..3f8adf7cb6 --- /dev/null +++ b/app/models/journeys/further_education_payments/courses_helper.rb @@ -0,0 +1,92 @@ +module Journeys + module FurtherEducationPayments + module CoursesHelper + include ActionView::Helpers::UrlHelper + include GovukVisuallyHiddenHelper + include GovukLinkHelper + + ALL_COURSE_FIELDS = %i[ + building_construction_courses + chemistry_courses + computing_courses + early_years_courses + engineering_manufacturing_courses + maths_courses + physics_courses + ].freeze + + ALL_SUBJECTS = ALL_COURSE_FIELDS.map { |course_field| course_field.to_s.gsub("_courses", "") }.freeze + + COURSE_DESCRIPTIONS_WITH_INLINE_LINKS = { + building_construction_courses: { + esfa_buildingconstruction: [ + "building and construction", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=7" + ], + level2_3_apprenticeship: [ + "construction and the built environment occupational route", + "https://occupational-maps.instituteforapprenticeships.org/maps/route/construction" + ] + }, + computing_courses: { + esfa_digitalpractitioners: [ + "digital technology for practitioners", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=23&PageSize=10&Sort=Status" + ], + esfa_digitalusers: [ + "digital technology for users", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=22&PageSize=10&Sort=Status" + ], + level2_3_apprenticeship: [ + "digital occupational route", + "https://occupational-maps.instituteforapprenticeships.org/maps/route/digital" + ] + }, + early_years_courses: { + coursetoeyq: [ + "early years qualification", + "https://www.gov.uk/government/publications/early-years-qualifications-achieved-in-england" + ] + }, + engineering_manufacturing_courses: { + esfa_engineering: [ + "engineering", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=13&PageSize=10&Sort=Status" + ], + esfa_manufacturing: [ + "manufacturing technologies", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=26&PageSize=10&Sort=Status" + ], + esfa_transportation: [ + "transportation operations and maintenance", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=47&PageSize=10&Sort=Status" + ], + level2_3_apprenticeship: [ + "engineering and manufacturing occupational route", + "https://occupational-maps.instituteforapprenticeships.org/maps/route/engineering-manufacturing" + ] + }, + maths_courses: { + esfa: [ + "mathematics and statistics", + "https://www.qualifications.education.gov.uk/Search?Status=Approved&Level=0,1,2,3,4&Sub=28&PageSize=10&Sort=Status" + ], + gcse_maths: [ + "other maths qualifications", + "https://submit-learner-data.service.gov.uk/find-a-learning-aim/LearningAimSearchResult?TeachingYear=2324&HasFilters=False&EFAFundingConditions=EFACONFUNDMATHS" + ] + } + }.freeze + + def course_option_description(course, opts = {}) + course_field = opts.key?(:i18n_form_namespace) ? opts[:i18n_form_namespace] : i18n_form_namespace + args = {i18n_form_namespace: course_field} + + text, url = COURSE_DESCRIPTIONS_WITH_INLINE_LINKS.dig(course_field.to_sym, course.to_sym) + args[:link] = govuk_link_to(text, url, new_tab: true) if text.present? && url.present? + + t("options.#{course}", args) + end + end + end +end diff --git a/app/models/journeys/further_education_payments/session_answers.rb b/app/models/journeys/further_education_payments/session_answers.rb index f18baa0178..260d94bace 100644 --- a/app/models/journeys/further_education_payments/session_answers.rb +++ b/app/models/journeys/further_education_payments/session_answers.rb @@ -15,6 +15,7 @@ class SessionAnswers < Journeys::SessionAnswers attribute :engineering_manufacturing_courses, default: [] attribute :maths_courses, default: [] attribute :physics_courses, default: [] + attribute :hours_teaching_eligible_subjects, :boolean attribute :teaching_qualification, :string attribute :subject_to_formal_performance_action, :boolean attribute :subject_to_disciplinary_action, :boolean @@ -39,6 +40,10 @@ def subject_to_formal_performance_action? def subject_to_disciplinary_action? !!subject_to_disciplinary_action end + + def hours_teaching_eligible_subjects? + !!hours_teaching_eligible_subjects + end end end end diff --git a/app/models/journeys/further_education_payments/slug_sequence.rb b/app/models/journeys/further_education_payments/slug_sequence.rb index 7b57776b5c..6d63873edb 100644 --- a/app/models/journeys/further_education_payments/slug_sequence.rb +++ b/app/models/journeys/further_education_payments/slug_sequence.rb @@ -16,7 +16,7 @@ class SlugSequence engineering-manufacturing-courses maths-courses physics-courses - teaching-courses + hours-teaching-eligible-subjects half-teaching-hours teaching-qualification poor-performance diff --git a/app/views/further_education_payments/claims/hours_teaching_eligible_subjects.html.erb b/app/views/further_education_payments/claims/hours_teaching_eligible_subjects.html.erb new file mode 100644 index 0000000000..2bc6951210 --- /dev/null +++ b/app/views/further_education_payments/claims/hours_teaching_eligible_subjects.html.erb @@ -0,0 +1,21 @@ +
+
+ <%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> + <%= f.govuk_error_summary %> + +

+ <%= @form.t(:question) %> +

+ +

+ At least 50% of your timetabled teaching hours must be spent teaching students of all ages in the following courses: +

+ + <%= govuk_list @form.courses, type: :bullet %> + + <%= f.govuk_collection_radio_buttons :hours_teaching_eligible_subjects, @form.radio_options, :id, :name, legend: { hidden: true } %> + + <%= f.govuk_submit %> + <% end %> +
+
diff --git a/app/views/further_education_payments/claims/teaching_courses.html.erb b/app/views/further_education_payments/claims/teaching_courses.html.erb deleted file mode 100644 index f6a61047d2..0000000000 --- a/app/views/further_education_payments/claims/teaching_courses.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

- FE teaching courses goes here -

- -<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> - <%= f.govuk_submit %> -<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index caa54f3233..a6195d6321 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -872,7 +872,7 @@ en: tlevel_building: T Level in building services engineering for construction tlevel_onsiteconstruction: T Level in onsite construction tlevel_design_surveying: T Level in design, surveying and planning for construction - level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} + level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} none: I do not teach any of these courses chemistry_courses: <<: *courses @@ -886,14 +886,14 @@ en: <<: *courses question: Which computing courses do you teach? options: - esfa_digitalpractitioners: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area - esfa_digitalusers: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + esfa_digitalpractitioners: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + esfa_digitalusers: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area digitalskills_quals: Digital functional skills qualifications and essential digital skills qualifications tlevel_digitalsupport: T Level in digital support services tlevel_digitalbusiness: T Level in digital business services tlevel_digitalproduction: T Level in digital production, design and development ib_certificate_compsci: International baccalaureate certificate in computer science - level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} + level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} none: I do not teach any of these courses early_years_courses: <<: *courses @@ -902,26 +902,26 @@ en: eylevel2: Early years practitioner (level 2) apprenticeship eylevel3: Early years educator (level 3) apprenticeship eytlevel: T Level in education and early years (early years educator) - coursetoeyq: A course that leads to an %{link} which enables providers to count the recipient in staff:child ratios + coursetoeyq: A course that leads to an %{link} which enables providers to count the recipient in staff:child ratios none: I do not teach any of these courses engineering_manufacturing_courses: <<: *courses question: Which engineering and manufacturing courses do you teach? options: - esfa_engineering: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area - esfa_manufacturing: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area - esfa_transportation: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + esfa_engineering: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + esfa_manufacturing: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + esfa_transportation: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area tlevel_design: T Level in design and development for engineering and manufacturing tlevel_maintenance: T Level in maintenance, installation and repair for engineering and manufacturing tlevel_engineering: T Level in engineering, manufacturing, processing and control - level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} + level2_3_apprenticeship: Level 2 or level 3 apprenticeships in the %{link} none: I do not teach any of these courses maths_courses: <<: *courses question: Which maths courses do you teach? options: - esfa: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area - gcse_maths: Maths GCSE, functional skills qualifications and %{link} approved for teaching to 16 to 19-year-olds who meet the condition of funding + esfa: ESFA-funded qualifications at level 3 and below in the %{link} sector subject area + gcse_maths: Maths GCSE, functional skills qualifications and %{link} approved for teaching to 16 to 19-year-olds who meet the condition of funding none: I do not teach any of these courses physics_courses: <<: *courses @@ -959,6 +959,10 @@ en: question: Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)? errors: inclusion: Select yes if at least half your timetabled teaching hours are spent teaching 16-19-year-olds, including those up to 25 with an Education, Health and Care Plan + hours_teaching_eligible_subjects: + question: Do you spend at least half of your timetabled teaching hours teaching these eligible courses? + errors: + inclusion: Select yes if spend at least half of your timetabled teaching hours teaching these eligible courses check_your_answers: part_one: primary_heading: Check your answers diff --git a/spec/features/further_education_payments/happy_js_path_spec.rb b/spec/features/further_education_payments/happy_js_path_spec.rb index 0d22d9fca7..f05448de08 100644 --- a/spec/features/further_education_payments/happy_js_path_spec.rb +++ b/spec/features/further_education_payments/happy_js_path_spec.rb @@ -47,7 +47,9 @@ check "T Level in building services engineering for construction" click_button "Continue" - expect(page).to have_content("FE teaching courses goes here") + expect(page).to have_content("Do you spend at least half of your timetabled teaching hours teaching these eligible courses?") + expect(page).to have_content("T Level in building services engineering for construction") + choose("Yes") click_button "Continue" expect(page).to have_content("Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?") diff --git a/spec/features/further_education_payments/happy_path_spec.rb b/spec/features/further_education_payments/happy_path_spec.rb index 0eb243b898..b2eea1cee1 100644 --- a/spec/features/further_education_payments/happy_path_spec.rb +++ b/spec/features/further_education_payments/happy_path_spec.rb @@ -73,7 +73,15 @@ check "A or AS level physics" click_button "Continue" - expect(page).to have_content("FE teaching courses goes here") + expect(page).to have_content("Do you spend at least half of your timetabled teaching hours teaching these eligible courses?") + expect(page).to have_content("T Level in building services engineering for construction") + expect(page).to have_content("GCSE chemistry") + expect(page).to have_content("T Level in digital support services") + expect(page).to have_content("T Level in education and early years (early years educator)") + expect(page).to have_content("T Level in design and development for engineering and manufacturing") + expect(page).to have_content("ESFA-funded qualifications at level 3 and below in the") + expect(page).to have_content("A or AS level physics") + choose("Yes") click_button "Continue" expect(page).to have_content("Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?") diff --git a/spec/forms/form_spec.rb b/spec/forms/form_spec.rb index db1c916e57..6f429a5ef6 100644 --- a/spec/forms/form_spec.rb +++ b/spec/forms/form_spec.rb @@ -163,6 +163,31 @@ def initialize(journey_session) end end + describe "#t" do + let(:form) { TestSlugForm.new(journey:, journey_session:, params:) } + let(:args) { {} } + let(:key) { "some_key" } + + before do + allow(I18n).to receive(:t) + form.t(key, args) + end + + context "no args" do + it do + expect(I18n).to have_received(:t).with("some_key", {scope: "test_i18n_ns.forms.test_slug"}) + end + end + + context "override i18n_form_namespace" do + let(:args) { {i18n_form_namespace: "overriden_ns"} } + + it do + expect(I18n).to have_received(:t).with("some_key", {scope: "test_i18n_ns.forms.overriden_ns"}) + end + end + end + describe "#permitted_params" do let(:claim_params) { {first_name: "test-value"} } diff --git a/spec/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form_spec.rb b/spec/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form_spec.rb new file mode 100644 index 0000000000..d6cd31b1e3 --- /dev/null +++ b/spec/forms/journeys/further_education_payments/hours_teaching_eligible_subjects_form_spec.rb @@ -0,0 +1,58 @@ +require "rails_helper" + +RSpec.describe Journeys::FurtherEducationPayments::HoursTeachingEligibleSubjectsForm, type: :model do + let(:journey) { Journeys::FurtherEducationPayments } + let(:journey_session) { create(:further_education_payments_session) } + + let(:params) do + ActionController::Parameters.new( + claim: { + hours_teaching_eligible_subjects: + } + ) + end + + subject do + described_class.new( + journey_session:, + journey:, + params: + ) + end + + describe "validations" do + let(:hours_teaching_eligible_subjects) { nil } + + it do + is_expected.not_to( + allow_value(nil) + .for(:hours_teaching_eligible_subjects) + .with_message("Select yes if spend at least half of your timetabled teaching hours teaching these eligible courses") + ) + end + end + + describe "#save" do + context "Yes" do + let(:hours_teaching_eligible_subjects) { true } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.hours_teaching_eligible_subjects } + .to(true) + ) + end + end + + context "No" do + let(:hours_teaching_eligible_subjects) { false } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.hours_teaching_eligible_subjects } + .to(false) + ) + end + end + end +end