Skip to content

Commit 3583df2

Browse files
authored
Merge pull request #2879 from DFE-Digital/AQTS-1164-dev-public-email-domain-blocking-eligibility-checker
2 parents 93acf31 + 8b7f22b commit 3583df2

29 files changed

+635
-175
lines changed

app/controllers/concerns/enforce_eligibility_question_order.rb

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@ module EnforceEligibilityQuestionOrder
88
def redirect_by_status
99
return if current_page_is_allowed?
1010

11-
expected_path = paths[eligibility_check.status(includes_prioritisation:)]
11+
expected_path =
12+
paths[
13+
eligibility_check.status(
14+
includes_prioritisation:,
15+
includes_email_domains_for_referees:,
16+
)
17+
]
1218
redirect_to(expected_path) if expected_path && expected_path != request.path
1319
end
1420

1521
private
1622

1723
def current_page_is_allowed?
18-
order = paths.keys.index(eligibility_check.status(includes_prioritisation:))
24+
order =
25+
paths.keys.index(
26+
eligibility_check.status(
27+
includes_prioritisation:,
28+
includes_email_domains_for_referees:,
29+
),
30+
)
1931
current_position = paths.values.index(request.path)
2032
current_position && order && current_position <= order
2133
end
@@ -27,16 +39,27 @@ def paths
2739
qualification: eligibility_interface_qualifications_path,
2840
degree: eligibility_interface_degree_path,
2941
work_experience: eligibility_interface_work_experience_path,
42+
work_experience_referee:
43+
eligibility_interface_work_experience_referee_path,
3044
misconduct: eligibility_interface_misconduct_path,
3145
work_experience_in_england:
3246
eligibility_interface_work_experience_in_england_path,
3347
teach_children: eligibility_interface_teach_children_path,
3448
qualified_for_subject: eligibility_interface_qualified_for_subject_path,
3549
result: eligibility_interface_result_path,
36-
}.slice(*eligibility_check.status_route(includes_prioritisation:))
50+
}.slice(
51+
*eligibility_check.status_route(
52+
includes_prioritisation:,
53+
includes_email_domains_for_referees:,
54+
),
55+
)
3756
end
3857

3958
def includes_prioritisation
4059
FeatureFlags::FeatureFlag.active?(:prioritisation)
4160
end
61+
62+
def includes_email_domains_for_referees
63+
FeatureFlags::FeatureFlag.active?(:email_domains_for_referees)
64+
end
4265
end

app/controllers/eligibility_interface/result_controller.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ class EligibilityInterface::ResultController < EligibilityInterface::BaseControl
66
def show
77
eligibility_check.complete! if eligibility_check.persisted?
88

9-
render eligibility_check.eligible? ? "eligible" : "ineligible"
9+
render(
10+
if eligibility_check.eligible?(includes_email_domains_for_referees:)
11+
"eligible"
12+
else
13+
"ineligible"
14+
end,
15+
)
16+
end
17+
18+
private
19+
20+
def includes_email_domains_for_referees
21+
FeatureFlags::FeatureFlag.active?(:email_domains_for_referees)
1022
end
1123
end

app/controllers/eligibility_interface/work_experience_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ def new
1414
def create
1515
@form = WorkExperienceForm.new(form_params.merge(eligibility_check:))
1616
if @form.save
17-
redirect_to %i[eligibility_interface misconduct]
17+
if FeatureFlags::FeatureFlag.active?(:email_domains_for_referees)
18+
redirect_to %i[eligibility_interface work_experience_referee]
19+
else
20+
redirect_to %i[eligibility_interface misconduct]
21+
end
1822
else
1923
render :new, status: :unprocessable_entity
2024
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
module EligibilityInterface
4+
class WorkExperienceRefereeController < BaseController
5+
include EnforceEligibilityQuestionOrder
6+
7+
def new
8+
@form =
9+
WorkExperienceRefereeForm.new(
10+
eligibility_check: eligibility_check,
11+
work_experience_referee: eligibility_check.work_experience_referee,
12+
)
13+
end
14+
15+
def create
16+
@form =
17+
WorkExperienceRefereeForm.new(form_params.merge(eligibility_check:))
18+
if @form.save
19+
redirect_to %i[eligibility_interface misconduct]
20+
else
21+
render :new, status: :unprocessable_entity
22+
end
23+
end
24+
25+
private
26+
27+
def form_params
28+
params.require(
29+
:eligibility_interface_work_experience_referee_form,
30+
).permit(:work_experience_referee)
31+
end
32+
end
33+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
class EligibilityInterface::WorkExperienceRefereeForm
4+
include ActiveModel::Model
5+
include ActiveModel::Attributes
6+
7+
attr_accessor :eligibility_check
8+
attribute :work_experience_referee, :boolean
9+
10+
validates :eligibility_check, presence: true
11+
validates :work_experience_referee, inclusion: { in: [true, false] }
12+
13+
def save
14+
return false unless valid?
15+
16+
eligibility_check.update!(work_experience_referee:)
17+
end
18+
end

app/models/eligibility_check.rb

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# qualified_for_subject :boolean
1515
# teach_children :boolean
1616
# work_experience :string
17+
# work_experience_referee :boolean
1718
# created_at :datetime not null
1819
# updated_at :datetime not null
1920
# region_id :bigint
@@ -89,6 +90,10 @@ def skip_additional_questions?
8990
country&.eligibility_skip_questions || false
9091
end
9192

93+
def reduced_evidence_accepted?
94+
region&.reduced_evidence_accepted || false
95+
end
96+
9297
def ineligible_reasons
9398
work_experience_ineligible = work_experience_under_9_months?
9499

@@ -118,16 +123,21 @@ def ineligible_reasons
118123
(:qualified_for_subject if qualified_for_subject_ineligible),
119124
(:misconduct if free_of_sanctions == false),
120125
(:work_experience if work_experience_ineligible),
126+
(:work_experience_referee if work_experience_referee == false),
121127
].compact
122128
end
123129

124-
def eligible?
130+
def eligible?(includes_email_domains_for_referees: false)
125131
if skip_additional_questions? && region.present? && qualification
126132
return true
127133
end
128134

129135
region.present? && qualification && degree && teach_children? &&
130-
free_of_sanctions && !work_experience_under_9_months?
136+
free_of_sanctions && !work_experience_under_9_months? &&
137+
(
138+
work_experience_referee? || reduced_evidence_accepted? ||
139+
!includes_email_domains_for_referees
140+
)
131141
end
132142

133143
def country_eligibility_status
@@ -155,7 +165,10 @@ def completed?
155165
completed_at.present?
156166
end
157167

158-
def status(includes_prioritisation: false)
168+
def status(
169+
includes_prioritisation: false,
170+
includes_email_domains_for_referees: false
171+
)
159172
return :country if country_code.blank?
160173

161174
return :result if country_eligibility_status == :ineligible
@@ -167,6 +180,12 @@ def status(includes_prioritisation: false)
167180
return :degree if degree.nil?
168181

169182
return :work_experience if work_experience.blank?
183+
184+
if includes_email_domains_for_referees && !reduced_evidence_accepted? &&
185+
work_experience_referee.nil?
186+
return :work_experience_referee
187+
end
188+
170189
return :misconduct if free_of_sanctions.nil?
171190

172191
if includes_prioritisation && eligible_work_experience_in_england.nil?
@@ -184,13 +203,23 @@ def status(includes_prioritisation: false)
184203
:result
185204
end
186205

187-
def status_route(includes_prioritisation: false)
206+
def status_route(
207+
includes_prioritisation: false,
208+
includes_email_domains_for_referees: false
209+
)
188210
if country_code.present? && country_eligibility_status == :ineligible
189211
%i[country result]
190212
elsif skip_additional_questions? && qualification
191213
%i[country region qualification result]
192214
else
193-
%i[country region qualification degree work_experience misconduct] +
215+
%i[country region qualification degree work_experience] +
216+
(
217+
if includes_email_domains_for_referees && !reduced_evidence_accepted?
218+
%i[work_experience_referee]
219+
else
220+
[]
221+
end
222+
) + %i[misconduct] +
194223
(
195224
if includes_prioritisation
196225
%i[work_experience_in_england]

app/views/eligibility_interface/misconduct/new.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
<%
2+
back_link_url = FeatureFlags::FeatureFlag.active?(:email_domains_for_referees) && !@region.reduced_evidence_accepted ? eligibility_interface_work_experience_referee_path : eligibility_interface_work_experience_path
3+
%>
4+
15
<% content_for :page_title, title_with_error_prefix("Do you have any sanctions or restrictions on your employment record?", error: @form.errors.any?) %>
2-
<% content_for :back_link_url, eligibility_interface_work_experience_path %>
6+
<% content_for :back_link_url, back_link_url %>
37

48
<%= form_with model: @form, url: [:eligibility_interface, :misconduct] do |f| %>
59
<%= f.govuk_error_summary %>

app/views/eligibility_interface/start/show.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
<li>completed all mandatory induction processes to gain full teacher registration in the country where you qualified</li>
4444
<li>qualifications to show you can teach children aged anywhere between 5 and 16 years old</li>
4545
<li>at least one school year (9 months) of experience employed as a teacher in any country, but must be from after you first became qualified to teach</li>
46+
<% if FeatureFlags::FeatureFlag.active?(:email_domains_for_referees) %>
47+
<li>references that can confirm your work history and have an email address that uses the school’s domain, for example, name@school.edu</li>
48+
<% end %>
4649
</ul>
4750

4851
<p class="govuk-body">Depending on the country that you trained to teach in, you may be required to have:</p>

app/views/eligibility_interface/work_experience/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
hint: { text: hint.html_safe }
2828
) %>
2929

30-
<% unless @region.reduced_evidence_accepted %>
30+
<% unless @region.reduced_evidence_accepted || FeatureFlags::FeatureFlag.active?(:email_domains_for_referees) %>
3131
<p class="govuk-body">You’ll need to provide references from your places of employment so we can verify your teaching work history.</p>
3232
<% end %>
3333

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<%
2+
hint = "
3+
You’ll need to provide references from your places of employment so we can verify your teaching work history. They must meet all of the following requirements:
4+
<ul class='govuk-list govuk-list--bullet govuk-hint'>
5+
<li>they have an email address that uses the institution’s domain, for example, name@institution.edu</li>
6+
<li>they are a senior member of staff that is still working at this institution (either a headteacher/principal, an assistant/deputy head, or an institution business manager)</li>
7+
<li>they are able to provide a reference in English</li>
8+
<li>they only comment on teaching work that you did after becoming a qualified teacher</li>
9+
</ul>
10+
".html_safe
11+
%>
12+
13+
<% content_for :page_title, title_with_error_prefix(t("helpers.legend.eligibility_interface_work_experience_referee_form.work_experience_referee"), error: @form.errors.any?) %>
14+
<% content_for :back_link_url, eligibility_interface_work_experience_path %>
15+
16+
<%= form_with model: @form, url: [:eligibility_interface, :work_experience_referee] do |f| %>
17+
<%= f.govuk_error_summary %>
18+
19+
<%= f.govuk_collection_radio_buttons(
20+
:work_experience_referee,
21+
[
22+
OpenStruct.new(label: 'Yes', value: true),
23+
OpenStruct.new(label: 'No', value: false)
24+
],
25+
:value,
26+
:label,
27+
legend: { size: 'l', tag: 'h1' },
28+
hint: { text: hint.html_safe }
29+
) %>
30+
31+
<%= govuk_details(summary_text: "About your references’ email addresses") do %>
32+
<p>A domain is the part of an email address that shows who provides it. It comes after the @ symbol. For example, in name@institution.edu the domain is institution.edu.</p>
33+
<p>We only accept references from official email addresses to verify they are genuine staff members of a recognised institution. To verify your work history, we will also check that the email domain is listed on the institution’s website.</p>
34+
<% end %>
35+
36+
<%= f.govuk_submit %>
37+
<% end %>

0 commit comments

Comments
 (0)