Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teacher degree apprenticeship filter to Manage #9406

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Course < ApplicationRecord
scitt_programme: 'SC',
scitt_salaried_programme: 'SSC',
pg_teaching_apprenticeship: 'TA',
teacher_degree_apprenticeship: 'TDA',
}

enum degree_grade: {
Expand Down
29 changes: 27 additions & 2 deletions app/models/provider_interface/provider_applications_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module ProviderInterface
class ProviderApplicationsFilter
include FilterParamsHelper

POSTGRADUATE_COURSES_PARAM_NAME = 'postgraduate_courses'.freeze
TEACHER_DEGREE_APPRENTICESHIP_PARAM_NAME = 'teacher_degree_apprenticeship_courses'.freeze
tomas-stefano marked this conversation as resolved.
Show resolved Hide resolved

attr_accessor :available_filters, :filter_selections, :provider_user
attr_reader :applied_filters

Expand All @@ -20,7 +23,7 @@ def initialize(params:, provider_user:, state_store:)
end

def filters
([] << search_filter << recruitment_cycle_filter << status_filter << provider_filter << accredited_provider_filter << subject_filter << study_modes_filter).concat(provider_locations_filters).compact
([] << search_filter << recruitment_cycle_filter << status_filter << provider_filter << accredited_provider_filter << subject_filter << study_modes_filter << course_type_filter).concat(provider_locations_filters).compact
end

def filtered?
Expand All @@ -44,7 +47,7 @@ def no_results_message
private

def parse_params(params)
compact_params(params.permit(:remove, :candidate_name, recruitment_cycle_year: [], provider: [], status: [], accredited_provider: [], provider_location: [], subject: [], study_mode: []).to_h)
compact_params(params.permit(:remove, :candidate_name, recruitment_cycle_year: [], provider: [], status: [], accredited_provider: [], provider_location: [], subject: [], study_mode: [], course_type: []).to_h)
end

def save_filter_state!
Expand Down Expand Up @@ -101,6 +104,28 @@ def status_filter
}
end

def course_type_filter
return unless FeatureFlag.active?(:teacher_degree_apprenticeship)

{
type: :checkboxes,
heading: I18n.t('provider_interface.filters.course_type.heading'),
name: 'course_type',
options: [
{
value: POSTGRADUATE_COURSES_PARAM_NAME,
label: I18n.t('provider_interface.filters.course_type.option_one'),
tomas-stefano marked this conversation as resolved.
Show resolved Hide resolved
checked: applied_filters[:course_type]&.include?(POSTGRADUATE_COURSES_PARAM_NAME),
},
{
value: TEACHER_DEGREE_APPRENTICESHIP_PARAM_NAME,
label: I18n.t('provider_interface.filters.course_type.option_two'),
checked: applied_filters[:course_type]&.include?(TEACHER_DEGREE_APPRENTICESHIP_PARAM_NAME),
},
],
}
end

def provider_filter
providers = ProviderOptionsService.new(provider_user).providers

Expand Down
15 changes: 15 additions & 0 deletions app/services/filter_application_choices_for_providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ def hide_in_reporting(application_choices, hide_in_reporting)
application_choices.where(candidate: { hide_in_reporting: })
end

def course_type(application_choices, course_type_filter)
return application_choices if course_type_filter.blank? || all_course_types?(course_type_filter)

if course_type_filter.include?('teacher_degree_apprenticeship_courses')
application_choices.joins(:current_course).where(current_course: { program_type: 'TDA' })
else
application_choices.joins(:current_course).where.not(current_course: { program_type: 'TDA' })
end
end

def all_course_types?(course_type_filter)
course_type_filter.compact_blank.sort == %w[postgraduate_courses teacher_degree_apprenticeship_courses]
tomas-stefano marked this conversation as resolved.
Show resolved Hide resolved
end

def create_filter_query(application_choices, filters)
filtered_application_choices = search(application_choices, filters[:candidate_name])
filtered_application_choices = recruitment_cycle_year(filtered_application_choices, filters[:recruitment_cycle_year])
Expand All @@ -101,6 +115,7 @@ def create_filter_query(application_choices, filters)
filtered_application_choices = course_subject(filtered_application_choices, filters[:subject])
filtered_application_choices = study_mode(filtered_application_choices, filters[:study_mode])
filtered_application_choices = hide_in_reporting(filtered_application_choices, filters[:hide_in_reporting])
filtered_application_choices = course_type(filtered_application_choices, filters[:course_type])
provider_location(filtered_application_choices, filters[:provider_location])
end
end
Expand Down
8 changes: 8 additions & 0 deletions config/locales/provider_interface/filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
provider_interface:
filters:
course_type:
heading: 'Course type'
option_one: 'Postgraduate courses'
option_two: 'Teaching degree apprenticeship (TDA) courses'

9 changes: 9 additions & 0 deletions spec/factories/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
uuid { SecureRandom.uuid }
end

trait :teacher_degree_apprenticeship do
apprenticeship
full_time
description { 'Teacher degree apprenticeship with QTS full time teaching apprenticeship' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description { 'Teacher degree apprenticeship with QTS full time teaching apprenticeship' }
description { 'Teaching degree apprenticeship with QTS full time teaching apprenticeship' }

Is it Teaching degree apprenticeship or Teacher degree apprenticeship? We are not consistent. it may be too late to change in some places (eg the programme_type), but we should make an effort where possible.

Copy link
Collaborator Author

@tomas-stefano tomas-stefano May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this comes from the content designer and from the prototype. I might keep as it is


qualifications { %w[qts undergraduate_degree] }
program_type { 'teacher_degree_apprenticeship' }
end

trait :previous_year do
recruitment_cycle_year { RecruitmentCycle.previous_year }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
StateStores::RedisStore.new(key: "#{described_class::STATE_STORE_KEY}_#{provider_user.id}")
end

before do
FeatureFlag.deactivate(:teacher_degree_apprenticeship)
end

describe '#filters' do
let(:headings) { filter.filters.map { |f| f[:heading] } }
let(:params) { ActionController::Parameters.new }
Expand Down Expand Up @@ -67,6 +71,23 @@
expect(headings).not_to include('Provider')
end
end

context 'when teacher degree apprenticeship feature flag active' do
let(:filter) do
described_class.new(params:,
provider_user:,
state_store:)
end

before do
FeatureFlag.activate(:teacher_degree_apprenticeship)
end

it 'does include the course type filter' do
expect(filter.filters.size).to be(7)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this adding value? If we add another filter this will fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just maintaned the same test that was there and added the tda filter. I think I will maintain this.

expect(headings).to include('Course type')
end
end
end

describe 'location filter' do
Expand Down
Loading
Loading