Skip to content

Commit

Permalink
Exclude 2025 and later participants from delivery partners
Browse files Browse the repository at this point in the history
We want to exclude participants in the 2025 cohort from the delivery partners
participants view. We also want to hide the 2025 and later cohorts from the
academic year dropdown.

This is indended to encourage lead providers to carry out their contractual
duties and ensure there is no ownness on the DfE to share details of
participants in 2025 and later cohorts.
  • Loading branch information
ethax-ross committed Feb 21, 2025
1 parent 16cd377 commit 106e69d
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 23 deletions.
10 changes: 8 additions & 2 deletions app/services/delivery_partners/participants_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(collection:, params:, training_record_states:)
end

def scope
scoped = collection
scoped = filter_out_post_2024_cohorts(collection)

if params[:query].present?
scoped = filter_query(scoped, params[:query])
Expand Down Expand Up @@ -61,7 +61,13 @@ def filter_role(scoped, role)
end
end

def filter_out_post_2024_cohorts(scoped)
scoped.joins(:cohort).where("start_year <= 2024")
end

def filter_academic_year(scoped, academic_year)
return collection.none unless academic_year.to_i.in?(academic_year_options.map(&:id))

scoped.includes(
:cohort,
).where(cohort: { start_year: academic_year })
Expand Down Expand Up @@ -91,7 +97,7 @@ def role_options

def academic_year_options
[OpenStruct.new(id: "", name: "")] +
Cohort.order(:start_year).map do |c|
Cohort.where("start_year <= ?", 2024).order(:start_year).map do |c|
OpenStruct.new(id: c.start_year, name: c.start_year)
end
end
Expand Down
17 changes: 16 additions & 1 deletion spec/features/delivery_partners/participants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

RSpec.feature "Delivery partner users participants", type: :feature do
let(:school) { create(:school) }
let(:school_cohort) { create(:school_cohort, school:) }
let(:cohort) { create(:cohort, start_year: 2024) }
let(:school_cohort) { create(:school_cohort, school:, cohort:) }
let(:participant_profile) { create(:ect_participant_profile, school_cohort:, training_status: "withdrawn") }

let(:delivery_partner_user) { create(:user, :delivery_partner) }
Expand Down Expand Up @@ -42,6 +43,15 @@
and_i_see_participant_details_csv_export
end

context "when the participant is in the 2025 cohort" do
let(:cohort) { create(:cohort, start_year: 2025) }

scenario "Visit participants page" do
then_i_see("Participants")
and_i_see_no_participant_details
end
end

context "Search query" do
scenario "None existing search term" do
when_i_fill_in("query", with: "MADE UP XXX123")
Expand Down Expand Up @@ -136,6 +146,11 @@ def and_i_see_participant_details
expect(page).to have_content(participant_profile.user.email)
end

def and_i_see_no_participant_details
expect(page).not_to have_content(participant_profile.user.full_name)
expect(page).not_to have_content(participant_profile.user.email)
end

def and_i_do_not_see_participant_details
expect(page).not_to have_content(participant_profile.user.full_name)
expect(page).not_to have_content(participant_profile.user.email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,25 @@
expect(participant_endpoint).to have_schedule_identifier schedule_identifier
end

scenario "The current delivery partner can locate a record for the ECT" do
given_i_sign_in_as_the_user_with_the_full_name delivery_partner_name

delivery_partner_portal = Pages::DeliveryPartnerPortal.loaded
delivery_partner_portal.get_participant(participant_full_name)

expect(delivery_partner_portal).to have_full_name participant_full_name
expect(delivery_partner_portal).to have_email_address participant_email
expect(delivery_partner_portal).to have_teacher_reference_number teacher_reference_number
expect(delivery_partner_portal).to have_participant_type long_participant_type
expect(delivery_partner_portal).to have_lead_provider_name lead_provider_name
expect(delivery_partner_portal).to have_school_name school_name
expect(delivery_partner_portal).to have_school_urn school.urn
expect(delivery_partner_portal).to have_academic_year start_year
expect(delivery_partner_portal).to have_training_record_status delivery_partner_record_state
context "when the participant cohort is 2024 or earlier" do
let(:start_year) { 2024 }

scenario "The current delivery partner can locate a record for the ECT" do
given_i_sign_in_as_the_user_with_the_full_name delivery_partner_name

delivery_partner_portal = Pages::DeliveryPartnerPortal.loaded
delivery_partner_portal.get_participant(participant_full_name)

expect(delivery_partner_portal).to have_full_name participant_full_name
expect(delivery_partner_portal).to have_email_address participant_email
expect(delivery_partner_portal).to have_teacher_reference_number teacher_reference_number
expect(delivery_partner_portal).to have_participant_type long_participant_type
expect(delivery_partner_portal).to have_lead_provider_name lead_provider_name
expect(delivery_partner_portal).to have_school_name school_name
expect(delivery_partner_portal).to have_school_urn school.urn
expect(delivery_partner_portal).to have_academic_year start_year
expect(delivery_partner_portal).to have_training_record_status delivery_partner_record_state
end
end

scenario "The Support for ECTs service can locate a record for the CIP ECT" do
Expand Down
51 changes: 46 additions & 5 deletions spec/services/delivery_partners/participants_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
require "rails_helper"

RSpec.describe DeliveryPartners::ParticipantsFilter do
let(:school_cohort1) { create(:school_cohort, cohort: Cohort.current) }
let(:school_cohort1) { create(:school_cohort, cohort: Cohort.find_by!(start_year: 2023)) }
let(:partnership1) { create(:partnership, lead_provider: create(:lead_provider, name: "LP1")) }
let(:induction_programme1) { create(:induction_programme, partnership: partnership1) }
let(:participant_profile1) { create(:mentor_participant_profile) }
let!(:induction_record1) { create(:induction_record, participant_profile: participant_profile1, induction_programme: induction_programme1, school_cohort: school_cohort1) }

let(:school_cohort2) { create(:school_cohort, cohort: Cohort.next) }
let(:school_cohort2) { create(:school_cohort, cohort: Cohort.find_by!(start_year: 2024)) }
let(:partnership2) { create(:partnership, lead_provider: create(:lead_provider, name: "LP2")) }
let(:induction_programme2) { create(:induction_programme, partnership: partnership2) }
let(:participant_profile2) { create(:ect_participant_profile, training_status: "deferred") }
let!(:induction_record2) { create(:induction_record, participant_profile: participant_profile2, induction_programme: induction_programme2, school_cohort: school_cohort2, training_status: "deferred") }

let(:delivery_partner) { create(:delivery_partner, partnerships: [partnership1, partnership2]) }
let(:school_cohort3) { create(:school_cohort, cohort: Cohort.find_by!(start_year: 2025)) }
let(:partnership3) { create(:partnership, lead_provider: create(:lead_provider, name: "LP3")) }
let(:induction_programme3) { create(:induction_programme, partnership: partnership3) }
let(:participant_profile3) { create(:ect_participant_profile, training_status: "deferred") }
let!(:induction_record3) { create(:induction_record, participant_profile: participant_profile3, induction_programme: induction_programme3, school_cohort: school_cohort3) }

let(:delivery_partner) { create(:delivery_partner, partnerships: [partnership1, partnership2, partnership3]) }

let(:collection) { DeliveryPartners::InductionRecordsQuery.new(delivery_partner:).induction_records }
let(:params) { {} }
let(:training_record_states) { DetermineTrainingRecordState.call(induction_records: collection) }

subject { described_class.new(collection:, params:, training_record_states:).scope.to_a }
let(:instance) { described_class.new(collection:, params:, training_record_states:) }

subject { instance.scope.to_a }

context "when there are no filters provided" do
it { is_expected.to contain_exactly(induction_record1, induction_record2) }
Expand Down Expand Up @@ -98,7 +106,13 @@
it { is_expected.to be_empty }
end

context "with academic_year" do
context "with academic_year not present in the options" do
let(:params) { { academic_year: 2025 } }

it { is_expected.to be_empty }
end

context "with academic_year present in the options" do
let(:params) { { academic_year: school_cohort1.start_year } }

it { is_expected.to contain_exactly(induction_record1) }
Expand All @@ -124,4 +138,31 @@
it { is_expected.to contain_exactly(induction_record1) }
end
end

describe "#role_options" do
subject(:options) { instance.role_options }

it { expect(options.map(&:id)).to eq(["", "ect", "mentor"]) }
it { expect(options.map(&:name)).to eq(["", "Early career teacher", "Mentor"]) }
end

describe "#academic_year_options" do
subject(:options) { instance.academic_year_options }

let(:expected_values) { [""] + Cohort.order(:start_year).pluck(:start_year).excluding(2025) }

before { expect(Cohort.where(start_year: 2025)).to be_exists }

it { expect(options.map(&:id)).to eq(expected_values) }
it { expect(options.map(&:name)).to eq(expected_values) }
end

describe "#status_options" do
subject(:options) { instance.status_options }

let(:expected_values) { I18n.t("status_tags.delivery_partner_participant_status").values.uniq }

it { expect(options.map(&:id)).to eq([""] + expected_values.pluck(:id)) }
it { expect(options.map(&:name)).to eq([""] + expected_values.pluck(:label)) }
end
end

0 comments on commit 106e69d

Please sign in to comment.