Skip to content

Commit

Permalink
Merge pull request #3014 from DFE-Digital/fe-ineligible-search
Browse files Browse the repository at this point in the history
[LUPEYALPHA-652] FE ineligible provider selected
  • Loading branch information
asmega authored Jul 23, 2024
2 parents 08e3253 + a6c1ba9 commit 021b8a1
Show file tree
Hide file tree
Showing 20 changed files with 643 additions and 98 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/college_search.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

var hiddenInput = form.querySelector("input#claim_school_id");
var hiddenInput = form.querySelector("input#claim_possible_school_id");

var schools = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ class FurtherEducationProvisionSearchForm < Form
MIN_LENGTH = 3

attribute :provision_search, :string
attribute :school_id, :string
attribute :possible_school_id, :string

validates :provision_search,
presence: {message: i18n_error_message(:blank)},
length: {minimum: MIN_LENGTH, message: i18n_error_message(:min_length)},
unless: proc { |object| object.school_id.present? }
unless: proc { |object| object.possible_school_id.present? }

def no_results?
provision_search.present? && provision_search.size >= MIN_LENGTH && !has_results
Expand All @@ -18,10 +18,18 @@ def no_results?
def save
return if invalid? || no_results?

journey_session.answers.assign_attributes(
provision_search:,
school_id:
)
reset_dependent_answers if changed_answer?

if possible_school_id.present?
journey_session.answers.assign_attributes(
possible_school_id:
)
else
journey_session.answers.assign_attributes(
provision_search:
)
end

journey_session.save!

true
Expand All @@ -30,7 +38,17 @@ def save
private

def has_results
School.open.search(provision_search).count > 0
School.search(provision_search).count > 0
end

def changed_answer?
possible_school_id != journey_session.answers.school_id
end

def reset_dependent_answers
journey_session.answers.assign_attributes(
school_id: nil
)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Journeys
module FurtherEducationPayments
class SelectProvisionForm < Form
attribute :school_id, :string # school GUID
attribute :possible_school_id, :string # school GUID

validates :school_id, presence: {message: i18n_error_message(:blank)}
validates :possible_school_id, presence: {message: i18n_error_message(:blank)}

def radio_options
results
Expand All @@ -12,7 +12,7 @@ def radio_options
def save
return unless valid?

journey_session.answers.assign_attributes(school_id:)
journey_session.answers.assign_attributes(school_id: possible_school_id)
journey_session.save!

true
Expand All @@ -21,10 +21,10 @@ def save
private

def results
@results ||= if journey_session.answers.school_id.present?
School.open.fe_only.where(id: school_id)
@results ||= if journey_session.answers.possible_school_id.present?
School.fe_only.where(id: possible_school_id)
else
School.open.fe_only.search(provision_search)
School.fe_only.search(provision_search)
end
end

Expand Down
30 changes: 30 additions & 0 deletions app/models/journeys/further_education_payments/session_answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module FurtherEducationPayments
class SessionAnswers < Journeys::SessionAnswers
attribute :teaching_responsibilities, :boolean
attribute :provision_search, :string
attribute :possible_school_id, :string # GUID
attribute :school_id, :string # GUID
attribute :contract_type, :string
attribute :fixed_term_full_year, :boolean
Expand All @@ -29,9 +30,17 @@ def policy
end

def school
return unless school_id

@school ||= School.find(school_id)
end

def possible_school
return unless possible_school_id

@possible_school ||= School.find(possible_school_id)
end

def teaching_responsibilities?
!!teaching_responsibilities
end
Expand Down Expand Up @@ -75,6 +84,27 @@ def less_than_half_hours_teaching_fe?
def hours_teaching_eligible_subjects?
!!hours_teaching_eligible_subjects
end

def eligible_fe_provider?
return unless school

EligibleFeProvider
.where(academic_year: AcademicYear.current)
.where(ukprn: school.ukprn)
.exists?
end

def ineligible_fe_provider?
return unless school

!eligible_fe_provider?
end

def fe_provider_closed?
return unless school

school.closed?
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ class SlugSequence
).freeze

def self.start_page_url
if Rails.env.production?
"https://www.example.com" # TODO: update to correct guidance
else
Rails.application.routes.url_helpers.landing_page_path("further-education-payments")
end
Rails.application.routes.url_helpers.landing_page_path("further-education-payments")
end

attr_reader :journey_session
Expand Down
2 changes: 2 additions & 0 deletions app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module FurtherEducationPayments
# Percentage of claims to QA
MIN_QA_THRESHOLD = 10

URL_SPREADSHEET_ELIGIBLE_PROVIDERS = "https://assets.publishing.service.gov.uk/media/667300fe64e554df3bd0db92/List_of_eligible_FE_providers_and_payment_value_for_levelling_up_premium.xlsx".freeze

# TODO: This is needed once the reply-to email address has been added to Gov Notify
def notify_reply_to_id
nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def ineligible?
def ineligibility_reason
if answers.teaching_responsibilities == false
:lack_teaching_responsibilities
elsif answers.ineligible_fe_provider? || answers.fe_provider_closed?
:fe_provider
elsif answers.taught_at_least_one_term == false
:must_teach_at_least_one_term
elsif !answers.recent_further_education_teacher?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
The further education (FE) provider you have entered is not eligible
</h1>

<p class="govuk-body">
The reason could be:
</p>

<%= govuk_list [
"the FE provider you have selected is not included in the #{govuk_link_to "list of eligible providers", Policies::FurtherEducationPayments::URL_SPREADSHEET_ELIGIBLE_PROVIDERS }".html_safe,
"the spelling of the FE provider does not match our records - check the spelling, including any apostrophes, hyphens or full stops used in the FE provider’s name",
"the FE provider you listed is closed - this could be the case if it has rebranded"
], type: :bullet %>

<p class="govuk-body">
Eligible providers include:
</p>

<%= govuk_list [
"FE colleges",
"sixth-form colleges",
"designated institutions",
"16 to 19 only academies and free schools"
], type: :bullet %>

<%= govuk_button_link_to "Change FE provider", claim_path(current_journey_routing_name, "further-education-provision-search") %>

<p class="govuk-body">
For more information, check the eligibility criteria for <%= govuk_link_to "levelling up premium payments for early career further education teachers", "https://www.gov.uk/guidance/levelling-up-premium-payments-for-fe-teachers", new_tab: true %>.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
html: { novalidate: false } do |f| %>
<%= f.govuk_error_summary %>

<%= f.hidden_field :school_id %>
<%= f.hidden_field :possible_school_id %>

<h1 class="govuk-heading-l">
An eligible further education (FE) provider in England must employ you as a teacher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= 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 %>

<%= f.govuk_collection_radio_buttons :school_id, @form.radio_options, :id, :name, :address,
<%= f.govuk_collection_radio_buttons :possible_school_id, @form.radio_options, :id, :name, :address,
legend: {
text: @form.t("heading"),
tag: "h1",
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ en:
heading: You are not eligible
teaching_less_than_2_5_next_term:
heading: You are not eligible
fe_provider:
heading: The further education (FE) provider you have entered is not eligible
teaching_responsibilities:
question: Are you a member of staff with teaching responsibilities?
errors:
Expand Down
5 changes: 5 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
end

if ENV["ENVIRONMENT_NAME"].start_with?("review")
EligibleFeProvidersImporter.new(
File.new(Rails.root.join("spec/fixtures/files/eligible_fe_providers.csv")),
AcademicYear.current
).run

SchoolDataImporterJob.perform_later if School.count < 100
end

Expand Down
7 changes: 7 additions & 0 deletions spec/factories/schools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@
end

trait :further_education do
ukprn { rand(10_000_000..19_000_000) }
phase { 6 }
end

trait :fe_eligible do
after(:create) do |school, evaluator|
create(:eligible_fe_provider, ukprn: school.ukprn)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.feature "Further education payments", js: true, flaky: true do
let(:college) { create(:school, :further_education) }
let(:college) { create(:school, :further_education, :fe_eligible) }

scenario "happy js path" do
when_further_education_payments_journey_configuration_exists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.feature "Further education payments" do
let(:college) { create(:school, :further_education) }
let(:college) { create(:school, :further_education, :fe_eligible) }

scenario "happy path claim" do
when_further_education_payments_journey_configuration_exists
Expand Down
Loading

0 comments on commit 021b8a1

Please sign in to comment.