Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/controllers/registration_wizard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class RegistrationWizardController < PublicPagesController
before_action :set_form
before_action :check_end_of_journey, only: %i[update]
before_action :check_course_defined, only: %i[show]
before_action :check_teacher_auth_user

rescue_from FundingEligibility::MissingMandatoryInstitution, with: :redirect_to_institution_picker
rescue_from RegistrationWizard::RemovedStep, with: :redirect_to_course_start_date
Expand Down Expand Up @@ -146,4 +147,13 @@ def wizard_params

params.fetch(:registration_wizard, {}).permit(RegistrationWizard.permitted_params_for_step(params[:step].underscore))
end

def check_teacher_auth_user
return unless @form.step_requires_login?
return if current_user&.teacher_auth_provider?

Sentry.capture_message("User attempted registration from GAI") if current_user&.get_an_identity_provider? # TODO: test

redirect_to registration_wizard_show_path("continue-to-login")
end
end
6 changes: 5 additions & 1 deletion app/forms/questionnaires/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def last_step?
false
end

def step_requires_login?
false
end

# Previous steps should lead to `closed` when registration is closed.
def previous_step
return :closed if Feature.registration_closed?
Expand Down Expand Up @@ -142,7 +146,7 @@ def funding_your_npq_step
end

def check_answers_step
if wizard.current_user
if wizard.current_user&.teacher_auth_provider? # TODO: test
:check_answers_and_submit
else
:check_answers
Expand Down
12 changes: 8 additions & 4 deletions app/forms/questionnaires/check_answers_and_submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def requirements_met?
# - sharing infomration agreement
end

def step_requires_login?
true
end

def last_step?
true
end

def previous_step
:share_provider
end
Expand All @@ -20,10 +28,6 @@ def next_step
# This is the last step, so there is no next step.
end

def last_step?
true
end

def show_previously_funded_alert?
wizard.store["pre_login_funding_eligiblity_status_code"] == :funded && user_previously_funded?
end
Expand Down
9 changes: 0 additions & 9 deletions app/forms/questionnaires/choose_an_npq_and_provider.rb

This file was deleted.

18 changes: 0 additions & 18 deletions app/forms/questionnaires/choose_your_npq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ def course

private

def store_lead_provider_id
return wizard.query_store.lead_provider.id if lead_provider_valid?

nil
end

def lead_provider_valid?
valid_providers.include?(wizard.query_store.lead_provider)
end

def valid_providers
LeadProvider.for(course:, cohort:)
end

def cohort
@cohort ||= Cohort.find_by(identifier: wizard.query_store.course_start_cohort)
end
Expand All @@ -90,10 +76,6 @@ def courses
Course.offered_in(cohort).where(display: true).order(:position)
end

def previous_course
wizard.query_store.course
end

def validate_course_exists
if course.blank?
errors.add(:course_identifier, :invalid)
Expand Down
15 changes: 10 additions & 5 deletions app/forms/questionnaires/choose_your_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def next_step

def previous_step
if course&.npqs? && wizard.query_store.inside_catchment?
:funding_eligibility_senco
:funding_eligibility_senco # TODO: check if this is still needed - create feature spec if so
elsif course&.ehco?
if wizard.query_store.declared_previous_funding?
:ehco_new_headteacher
Expand All @@ -37,12 +37,16 @@ def previous_step
else
:funding_your_ehco
end
elsif wizard.query_store.maths_understanding?
:funding_eligibility_maths # TODO: test
elsif wizard.query_store.declared_previous_funding?
:funding_your_npq
elsif course&.npqh? && eligible_for_funding?
:possible_funding
:work_setting # TODO: test
elsif wizard.query_store.approved_itt_provider? || wizard.query_store.referred_by_return_to_teaching_adviser?
show_eligibility_step # TODO: test
elsif !eligible_for_funding? && !funding_eligibility_calculator.subject_to_review?
:funding_your_npq # TODO: test
else
:funding_your_npq
show_eligibility_step # TODO: test
end
end

Expand Down Expand Up @@ -74,6 +78,7 @@ def funding_eligibility_calculator
institution: query_store.institution,
approved_itt_provider: approved_itt_provider?,
inside_catchment: inside_catchment?,
user_ecf_id: query_store.user_ecf_id,
query_store: wizard.query_store,
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/forms/questionnaires/continue_to_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def previous_step
end

def next_step
:check_answers_and_submit
# next_step not used here - the login callback handles this
end
end
end
6 changes: 4 additions & 2 deletions app/forms/questionnaires/course_start_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def requirements_met?
end

def next_step
if Cohort.find_by(identifier: course_start_cohort).funded?
if changing_answer?
:choose_your_provider # TODO: test
elsif Cohort.find_by(identifier: course_start_cohort).funded?
:check_funding
else
:choose_your_npq
Expand All @@ -53,7 +55,7 @@ def previous_step
end

def return_to_regular_flow_on_change?
true
false
end

private
Expand Down
4 changes: 0 additions & 4 deletions app/forms/questionnaires/ehco_possible_funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ def next_step
def previous_step
:ehco_new_headteacher
end

def course
@course ||= wizard.query_store.course
end
end
end
2 changes: 1 addition & 1 deletion app/forms/questionnaires/ehco_unavailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def previous_step
end

def next_step
:choose_your_provider
# you cannot proceed any further from this step
end
end
end
12 changes: 7 additions & 5 deletions app/forms/questionnaires/funding_your_npq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ def self.permitted_params
end

def previous_step
:ineligible_for_funding
if wizard.query_store.declared_previous_funding?
:ineligible_for_funding_previously_funded # TODO: test
elsif wizard.query_store.asked_to_continue_without_checking_funding? || wizard.query_store.inside_catchment? # TODO: test
:ineligible_for_funding
else
:work_setting
end
end

def next_step
Expand All @@ -24,10 +30,6 @@ def next_step
end
end

def course
@course ||= wizard.query_store.course
end

def questions
[
QuestionTypes::RadioButtonGroup.new(
Expand Down
2 changes: 1 addition & 1 deletion app/forms/questionnaires/have_ofsted_urn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def next_step
end

def previous_step
:kind_of_nursery
:kind_of_nursery # TODO: test
end

def questions
Expand Down
38 changes: 17 additions & 21 deletions app/forms/questionnaires/ineligible_for_funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ class UnexpectedEligibilityStatusCode < StandardError; end
def previous_step
return :teacher_catchment unless course

if !wizard.query_store.inside_catchment? && wizard.query_store.teacher_catchment_specified?
# TODO: simplify logic
# maybe:
# - have a method: course_has_additional_eligibility_questions? (for npqlpm, npqs, ehco)
# - have logic somewhere for each course, detailing the additional questions
if !query_store.inside_catchment? && query_store.teacher_catchment_specified?
:teacher_catchment
elsif works_in_another_setting? && employment_type_other?
:choose_your_npq # TODO: test
elsif query_store.ofsted_route?
:have_ofsted_urn # TODO: test
elsif query_store.works_in_childcare?
:kind_of_nursery # TODO: test - this line needs to be after have_ofsted_urn - test this
elsif query_store.works_in_another_setting?
:your_employer # TODO: test
elsif course.ehco?
if wizard.query_store.declared_previous_funding?
:funding_history
else
:ehco_new_headteacher
end
:ehco_new_headteacher
elsif course.npqlpm?
:maths_eligibility_teaching_for_mastery # TODO: test
elsif course.npqs?
:senco_in_role # TODO: test
else
:your_employer
:work_setting
end
end

Expand Down Expand Up @@ -78,21 +82,13 @@ def funding_eligibility
@funding_eligibility ||= FundingEligibility.new_from_query_store(
course:,
institution: query_store.institution,
approved_itt_provider: approved_itt_provider?,
inside_catchment: inside_catchment?,
approved_itt_provider: query_store.approved_itt_provider?,
inside_catchment: query_store.inside_catchment?,
user_ecf_id: query_store.user_ecf_id,
query_store: wizard.query_store,
query_store: query_store,
)
end

delegate :course,
:lead_provider,
:new_headteacher?,
:inside_catchment?,
:approved_itt_provider?,
:lead_mentor_for_accredited_itt_provider?,
:works_in_another_setting?,
:employment_type_other?,
to: :query_store
delegate :course, :lead_provider, to: :query_store
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def next_step
end

def previous_step
:choose_your_npq
:work_setting
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/forms/questionnaires/possible_funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def previous_step
else
:maths_understanding_of_approach
end
elsif wizard.query_store.approved_itt_provider?
:itt_provider # TODO: test
elsif wizard.query_store.employment_type_needs_employer_name?
:your_employer # TODO: test
else
:work_setting
end
Expand Down
45 changes: 0 additions & 45 deletions app/forms/questionnaires/provider_check.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/forms/questionnaires/teacher_catchment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def return_to_regular_flow_on_change?
end

def next_step
if teacher_catchment == "england"
if teacher_catchment == "england" # TODO: change this so it work when going back
:choose_your_npq
else
:ineligible_for_funding
Expand Down
6 changes: 4 additions & 2 deletions app/forms/questionnaires/work_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ def next_step
return :your_employment
end

show_eligibility_step
return show_eligibility_step if wizard.query_store.course.ehco? # TODO: test

funding_your_npq_step # TODO: test
end

def previous_step
if wizard.query_store.declared_previous_funding?
if wizard.query_store.course&.ehco?
:funding_your_ehco
else
:ineligible_for_funding_previously_funded
:funding_your_npq # TODO: test
end
else
:funding_history
Expand Down
Loading
Loading