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 1 commit
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 @@ -20,7 +20,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 +44,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 +101,31 @@ def status_filter
}
end

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

postgraduate_courses_param_name = 'postgraduate_courses'
teacher_degree_apprenticeship_param_name = 'teacher_degree_apprenticeship_courses'

{
type: :checkboxes,
heading: 'Course type',
tomas-stefano marked this conversation as resolved.
Show resolved Hide resolved
name: 'course_type',
options: [
{
value: postgraduate_courses_param_name,
label: 'Postgraduate courses',
checked: applied_filters[:course_type]&.include?(postgraduate_courses_param_name),
},
{
value: teacher_degree_apprenticeship_param_name,
label: 'Teaching degree apprenticeship (TDA) courses',
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
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
148 changes: 128 additions & 20 deletions spec/system/provider_interface/provider_applications_filter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.feature 'Providers should be able to filter applications' do
RSpec.describe 'Providers should be able to filter applications' do
include CourseOptionHelpers
include DfESignInHelpers

Expand All @@ -26,27 +26,29 @@

then_i_expect_to_see_the_filter_dialogue

then_i_location_filters_should_not_be_visible
then_location_filters_are_not_visible

then_i_can_see_applications_from_the_previous_year_too

and_teacher_degree_apprenticeship_filter_is_not_visible

when_i_filter_for_rejected_applications
then_only_rejected_applications_should_be_visible
and_a_rejected_tag_should_be_visible
and_the_rejected_tickbox_should_still_be_checked
then_only_rejected_applications_are_visible
and_a_rejected_tag_is_visible
and_the_rejected_tickbox_is_checked

when_i_filter_for_applications_that_i_do_not_have
then_i_should_see_the_no_filter_results_error_message
then_i_see_the_no_filter_results_error_message
then_i_expect_to_see_the_filter_dialogue

when_i_filter_for_rejected_and_offered_applications
then_only_rejected_and_offered_applications_should_be_visible
then_only_rejected_and_offered_applications_are_visible

when_i_clear_the_filters
then_i_expect_all_applications_to_be_visible

when_i_filter_by_providers
then_location_filters_should_be_visible
then_location_filters_are_visible
then_i_only_see_applications_for_a_given_provider
then_i_expect_the_relevant_provider_tags_to_be_visible

Expand All @@ -61,11 +63,11 @@
when_i_click_to_remove_an_accredited_provider_tag

when_i_filter_by_providers
then_i_should_see_locations_that_belong_to_all_of_the_selected_providers_that_have_more_than_one_site
then_i_see_locations_that_belong_to_all_of_the_selected_providers_that_have_more_than_one_site

when_i_clear_the_filters
when_i_filter_by_a_specific_provider
then_i_should_only_see_locations_that_belong_to_that_provider
then_i_only_see_locations_that_belong_to_that_provider

when_i_filter_by_provider_location
then_i_only_see_applications_for_that_provider_location
Expand Down Expand Up @@ -116,10 +118,35 @@
and_i_click_the_sign_out_button
end

scenario 'when teacher degree apprenticeship is active' do
tomas-stefano marked this conversation as resolved.
Show resolved Hide resolved
given_i_am_a_provider_user_with_dfe_sign_in
and_teacher_degree_apprenticeship_feature_flag_is_active
and_i_am_permitted_to_see_applications_from_multiple_providers
and_my_organisation_has_courses_with_applications_without_accredited_providers
and_my_organisation_has_courses_that_awards_a_degree
and_i_sign_in_to_the_provider_interface

when_i_visit_the_provider_page
then_teacher_degree_apprenticeship_filter_is_visible

when_i_filter_by_postgraduate_courses
then_i_only_see_postgraduate_applications

when_i_filter_by_teacher_degree_apprenticeship_courses
then_i_only_see_teacher_degree_apprenticeship_applications

when_i_check_both_course_types_filter
then_i_see_postgraduate_and_teacher_degree_apprenticeship_applications
end

def and_i_click_the_sign_out_button
click_link_or_button 'Sign out'
end

def and_teacher_degree_apprenticeship_feature_flag_is_active
FeatureFlag.activate(:teacher_degree_apprenticeship)
end

def and_my_organisation_has_courses_with_applications_without_accredited_providers
course_option_one = course_option_for_provider(provider: current_provider,
site:,
Expand All @@ -136,26 +163,62 @@ def and_my_organisation_has_courses_with_applications_without_accredited_provide
build(:application_form, first_name: 'Greg', last_name: 'Taft'), updated_at: 4.days.ago)
end

def and_my_organisation_has_courses_that_awards_a_degree
course_option_one = course_option_for_provider(provider: current_provider,
site:,
course: build(:course,
:teacher_degree_apprenticeship,
name: 'Alchemy',
provider: current_provider))

course_option_two = course_option_for_provider(provider: second_provider, course: build(:course, :teacher_degree_apprenticeship, name: 'Science', provider: second_provider))

course_option_three = course_option_for_provider(provider: second_provider, course: build(:course, :teacher_degree_apprenticeship, name: 'Biology', provider: second_provider))

create(:application_choice, :awaiting_provider_decision, course_option: course_option_one, status: 'withdrawn', application_form:
build(:application_form, first_name: 'Andres', last_name: 'Bartell'), updated_at: 5.days.ago)

create(:application_choice, :awaiting_provider_decision, course_option: course_option_two, status: 'offer', application_form:
build(:application_form, first_name: 'Quinton', last_name: 'Marks'), updated_at: 4.days.ago)

create(:application_choice, :awaiting_provider_decision, current_course_option: course_option_three, status: 'offer', application_form:
build(:application_form, first_name: 'Leland', last_name: 'Harris'), updated_at: 4.days.ago)
end

def and_teacher_degree_apprenticeship_filter_is_not_visible
expect(page).to have_content('Filter')
expect(page).to have_no_content('Course type')
expect(page).to have_no_content('Postgraduate courses')
expect(page).to have_no_content('Teaching degree apprenticeship (TDA) courses')
end

def then_teacher_degree_apprenticeship_filter_is_visible
expect(page).to have_content('Filter')
expect(page).to have_content('Course type')
expect(page).to have_content('Postgraduate courses')
expect(page).to have_content('Teaching degree apprenticeship (TDA) courses')
end

def then_i_do_not_expect_to_see_the_accredited_providers_filter_heading
expect(page).to have_content('Filter')
expect(page).to have_no_content('Accredited provider')
end

def then_i_should_see_locations_that_belong_to_all_of_the_selected_providers_that_have_more_than_one_site
def then_i_see_locations_that_belong_to_all_of_the_selected_providers_that_have_more_than_one_site
expect(page).to have_content('Locations for Hoth Teacher Training')
expect(page).to have_content('Locations for Caladan University')
expect(page).to have_no_content('Locations for University of Arrakis')
end

def then_i_should_only_see_locations_that_belong_to_that_provider
def then_i_only_see_locations_that_belong_to_that_provider
expect(page).to have_no_content('Locations for Caladan University')
end

def then_location_filters_should_be_visible
def then_location_filters_are_visible
expect(page).to have_content('Locations for')
end

def then_i_location_filters_should_not_be_visible
def then_location_filters_are_not_visible
expect(page).to have_no_content('Locations for')
end

Expand All @@ -167,7 +230,48 @@ def then_i_only_see_applications_for_that_provider_location

def when_i_filter_by_provider_location
find_by_id("provider_location-#{site.provider_id}_#{site.name}_#{site.code}").set(true)
click_link_or_button('Apply filters')
and_i_apply_the_filters
end

def when_i_filter_by_postgraduate_courses
check 'Postgraduate courses'
and_i_apply_the_filters
end

def then_i_only_see_postgraduate_applications
expect(page).to have_content('Jim James')
expect(page).to have_content('Greg Taft')
expect(page).to have_no_content('Andres Bartell')
expect(page).to have_no_content('Quinton Marks')
expect(page).to have_no_content('Leland Harris')
end

def when_i_filter_by_teacher_degree_apprenticeship_courses
uncheck 'Postgraduate courses'
check 'Teaching degree apprenticeship (TDA) courses'
and_i_apply_the_filters
end

def then_i_only_see_teacher_degree_apprenticeship_applications
expect(page).to have_content('Andres Bartell')
expect(page).to have_content('Quinton Marks')
expect(page).to have_content('Leland Harris')
expect(page).to have_no_content('Jim James')
expect(page).to have_no_content('Greg Taft')
end

def when_i_check_both_course_types_filter
check 'Postgraduate courses'
check 'Teaching degree apprenticeship (TDA) courses'
and_i_apply_the_filters
end

def then_i_see_postgraduate_and_teacher_degree_apprenticeship_applications
expect(page).to have_content('Andres Bartell')
expect(page).to have_content('Quinton Marks')
expect(page).to have_content('Leland Harris')
expect(page).to have_content('Jim James')
expect(page).to have_content('Greg Taft')
end

def and_i_expect_the_relevant_provider_location_tags_to_be_visible
Expand Down Expand Up @@ -262,15 +366,15 @@ def when_i_filter_for_rejected_applications
click_link_or_button('Apply filters')
end

def then_only_rejected_applications_should_be_visible
def then_only_rejected_applications_are_visible
expect(page).to have_css('.app-application-cards', text: 'Rejected')
expect(page).to have_no_css('.app-application-cards', text: 'Offer')
expect(page).to have_no_css('.app-application-cards', text: 'Application withdrawn')
expect(page).to have_no_css('.app-application-cards', text: 'Declined')
expect(page).to have_no_css('.app-application-cards', text: 'Offer withdrawn')
end

def and_the_rejected_tickbox_should_still_be_checked
def and_the_rejected_tickbox_is_checked
rejected_checkbox = find_by_id('status-rejected')
expect(rejected_checkbox.checked?).to be(true)
end
Expand All @@ -281,7 +385,7 @@ def when_i_filter_for_applications_that_i_do_not_have
click_link_or_button('Apply filters')
end

def then_i_should_see_the_no_filter_results_error_message
def then_i_see_the_no_filter_results_error_message
expect(page).to have_content('There are no results for the selected filter.')
end

Expand All @@ -292,7 +396,7 @@ def when_i_filter_for_rejected_and_offered_applications
click_link_or_button('Apply filters')
end

def then_only_rejected_and_offered_applications_should_be_visible
def then_only_rejected_and_offered_applications_are_visible
expect(page).to have_css('.app-application-cards', text: 'Rejected')
expect(page).to have_css('.app-application-cards', text: 'Offer')
expect(page).to have_no_css('.app-application-cards', text: 'Application withdrawn')
Expand Down Expand Up @@ -361,7 +465,7 @@ def and_the_remaining_filters_to_still_apply
expect(page).to have_css('.app-application-cards', text: 'Caladan University')
end

def and_a_rejected_tag_should_be_visible
def and_a_rejected_tag_is_visible
expect(page).to have_css('.moj-filter-tags', text: 'Rejected')
end

Expand All @@ -374,4 +478,8 @@ def then_i_expect_all_applications_to_be_visible_again
expect(page).to have_content('Tom Jones')
expect(page).to have_content('Jim James')
end

def and_i_apply_the_filters
click_link_or_button('Apply filters')
end
end
Loading