Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kenfodder committed Jul 9, 2024
1 parent cd6264f commit 2a21f92
Show file tree
Hide file tree
Showing 21 changed files with 325 additions and 136 deletions.
4 changes: 3 additions & 1 deletion app/forms/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand All @@ -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
Expand Down
Loading

0 comments on commit 2a21f92

Please sign in to comment.