Skip to content

Commit

Permalink
[2288] Improve Locations (1/6) Add Training Location Information to c…
Browse files Browse the repository at this point in the history
…ourse Page (#4522)

* [2288] Update school placements h1

* [2288] Remove school placements info

* [2288] Add intro paragraph below the callout box

Different content depending on whether the course is salaried or not

* [2288] Update contents

* [2288] Add placement schools/study sites description details

* [2288] Refactor to use the pluralize method

* [2288] Refactor to use govuk component

* [2288] Differentiate fee and salary location text

* [2288] Add both salaried and fee previews

---------

Co-authored-by: Iain McNulty <[email protected]>
  • Loading branch information
avinhurry and inulty-dfe authored Sep 20, 2024
1 parent 5e701ba commit 2e8eb75
Show file tree
Hide file tree
Showing 11 changed files with 362 additions and 85 deletions.
24 changes: 12 additions & 12 deletions app/components/find/courses/about_schools_component/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
<% end %>
<% end %>

<% if course.fee_based? %>
<p class="govuk-body">
You’ll be placed in schools for most of your course to get classroom experience. You will also spend time at a location where you will study.
</p>
<% else %>
<p class="govuk-body">
You will spend most of your time in one school which will employ you. You will also spend some time in another school and at a location where you will study.
</p>
<% end %>

<%= render Find::Courses::TrainingLocations::View.new(course:, preview: preview?(params)) %>

<% if course.published_how_school_placements_work.present? %>
<%= markdown(course.published_how_school_placements_work) %>
<% elsif course.how_school_placements_work.present? %>
Expand Down Expand Up @@ -43,17 +55,5 @@
<% end %>
</ul>
<% end %>

<% if course.site_statuses.map(&:site).uniq.any? %>
<h3 class="govuk-heading-m">
<%= course.placements_heading %>
</h3>

<p class="govuk-body"><%= t(".work_with_schools") %></p>

<p class="govuk-body">
<%= govuk_link_to(t(".view_list_of_school_placements"), placements_url) %>
</p>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% end %>
<li><%= govuk_link_to t(".fees_and_financial_support"), "#section-financial-support" %></li>
<% if how_school_placements_work.present? || program_type == "higher_education_programme" || program_type == "scitt_programme" || preview? %>
<li><%= govuk_link_to t(".how_school_placements_work"), "#training-locations" %></li>
<li><%= govuk_link_to t(".where_you_will_train"), "#training-locations" %></li>
<% end %>
<% if interview_process.present? %>
<li><%= govuk_link_to t(".interview_process"), "#section-interviews" %></li>
Expand Down
26 changes: 26 additions & 0 deletions app/components/find/courses/training_locations/view.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%= govuk_summary_list(actions: false) do |summary_list| %>
<%= summary_list.with_row do |row| %>
<%= row.with_key { top_heading } %>
<%= row.with_value do %>
<p class="govuk-body"><%= potential_placements_text %></p>
<%= govuk_link_to(t("view_list_of_school_placements"), placements_url) %>
<p class="govuk-hint govuk-!-font-size-16">Locations can change and are not guaranteed</p>
<% end %>
<% end %>
<%= summary_list.with_row do |row| %>
<%= row.with_key { bottom_heading } %>
<%= row.with_value do %>
<p class="govuk-body"><%= potential_study_sites_text %></p>
<ul class="govuk-list govuk-list--spaced">
<% course.study_sites.each do |study_site| %>
<li>
<p class="govuk-hint govuk-!-font-size-16">
<strong><%= smart_quotes(study_site.location_name) %></strong><br>
<%= smart_quotes(study_site.decorate.full_address) %>
</p>
</li>
<% end %>
</ul>
<% end %>
<% end %>
<% end %>
58 changes: 58 additions & 0 deletions app/components/find/courses/training_locations/view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

module Find
module Courses
module TrainingLocations
class View < ViewComponent::Base
include PublishHelper
include PreviewHelper

attr_reader :course, :preview

def initialize(course:, preview: false)
@course = course
@preview = preview
super
end

def placements_url
if preview
placements_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
else
find_placements_path(course.provider_code, course.course_code)
end
end

def potential_placements_text
if course.fee_based?
pluralize(course.sites.size, 'potential placement location')
else
pluralize(course.sites.size, 'potential employing school')
end
end

def potential_study_sites_text
return 'Not listed yet' if course.study_sites.none?

if course.study_sites.one?
'1 study site'
else
"#{course.study_sites.size} potential study sites"
end
end

def top_heading
course.fee_based? ? 'Placement schools' : 'Employing schools'
end

def bottom_heading
'Where you will study'
end
end
end
end
end
2 changes: 2 additions & 0 deletions config/locales/en/components/find/training_locations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
view_list_of_school_placements: View list of school placements
5 changes: 2 additions & 3 deletions config/locales/find.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ en:
contents_component:
view:
course_details: Course details
how_school_placements_work: How school placements work
where_you_will_train: Where you will train
training_with_disabilities: Training with disabilities
fees_and_financial_support: Fees and financial support
salary: Salary
Expand Down Expand Up @@ -176,8 +176,7 @@ en:
contact: Contact %{provider_name}
about_schools_component:
view:
heading: How school placements work
view_list_of_school_placements: View list of school placements
heading: Where you will train
work_with_schools: We work with the following schools to provide your school placements.
placements:
heading: School placements at %{provider_name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ module Find
module Courses
module AboutSchoolsComponent
class ViewPreview < ViewComponent::Preview
def hei_minimum
def hei_minimum_without_salary
course = Course.new(course_code: 'FIND',
provider: Provider.new(provider_code: 'DFE', recruitment_cycle: RecruitmentCycle.current),
program_type: 'higher_education_programme',
level: 'further_education').decorate
level: 'further_education',
funding: 'fee').decorate
render Find::Courses::AboutSchoolsComponent::View.new(course)
end

def hei_minimum_with_salary
course = Course.new(course_code: 'FIND',
provider: Provider.new(provider_code: 'DFE', recruitment_cycle: RecruitmentCycle.current),
program_type: 'higher_education_programme',
level: 'further_education',
funding: 'salary').decorate
render Find::Courses::AboutSchoolsComponent::View.new(course)
end

Expand Down Expand Up @@ -38,17 +48,20 @@ def mock_scitt_course
placements_heading: 'How placements work',
program_type: 'scitt_programme',
study_sites: [fake_study_site],
sites: [fake_study_site],
site_statuses: [SiteStatus.new(id: 2_245_455, course_id: 12_983_436, publish: 'published', site_id: 11_228_658, status: 'running', vac_status: 'part_time_vacancies'), SiteStatus.new(id: 22_454_556, course_id: 12_983_436, publish: 'published', site_id: 11_228_659, status: 'running', vac_status: 'part_time_vacancies')])
end

def mock_hei_course
FakeCourse.new(provider: Provider.new(provider_code: 'DFE'),
provider_code: '1BJ',
course_code: 'ZZZZ',
is_fee_based: true,
published_how_school_placements_work: 'you will go on placement and learn more',
placements_heading: 'How placements work',
program_type: 'higher_education_programme',
study_sites: [fake_study_site],
sites: [fake_study_site],
site_statuses: [SiteStatus.new(id: 2_245_455, course_id: 12_983_436, publish: 'published', site_id: 11_228_658, status: 'running', vac_status: 'part_time_vacancies'), SiteStatus.new(id: 22_454_556, course_id: 12_983_436, publish: 'published', site_id: 11_228_659, status: 'running', vac_status: 'part_time_vacancies')])
end

Expand All @@ -58,7 +71,7 @@ def fake_study_site

class FakeCourse
include ActiveModel::Model
attr_accessor(:provider, :provider_code, :course_code, :published_how_school_placements_work, :placements_heading, :program_type, :study_sites, :site_statuses)
attr_accessor(:provider, :provider_code, :course_code, :published_how_school_placements_work, :placements_heading, :program_type, :study_sites, :site_statuses, :is_fee_based, :sites)

def higher_education_programme?
true
Expand All @@ -67,6 +80,10 @@ def higher_education_programme?
def preview_site_statuses
site_statuses.sort_by { |status| status.site.location_name }
end

def fee_based?
is_fee_based
end
end
end
end
Expand Down
83 changes: 20 additions & 63 deletions spec/components/find/courses/about_schools_component/view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

result = render_inline(described_class.new(course))

expect(result.text).to include('How school placements work')
expect(result.text).to include('Where you will train')
end
end
end
Expand All @@ -31,31 +31,36 @@
end
end

context 'course with site' do
it 'renders the school placement heading' do
provider = build(:provider)
context 'salaried course' do
it 'renders the correct content' do
course = build(:course,
provider:,
site_statuses: [
build(:site_status, site: build(:site))
]).decorate
funding: 'salary').decorate

result = render_inline(described_class.new(course))

expect(result.text).to include(course.placements_heading)
expect(result.text).to include('You will spend most of your time in one school which will employ you. You will also spend some time in another school and at a location where you will study.')
end
end

context 'course with no site' do
it 'does not render the school placement heading' do
provider = build(:provider)
context 'apprenticeship course' do
it 'renders the correct content' do
course = build(:course,
site_statuses: [],
provider:).decorate
funding: 'apprenticeship').decorate

result = render_inline(described_class.new(course))

expect(result.text).not_to include(course.placements_heading)
expect(result.text).to include('You will spend most of your time in one school which will employ you. You will also spend some time in another school and at a location where you will study.')
end
end

context 'fee paying course' do
it 'renders the correct content' do
course = build(:course,
funding: 'fee').decorate

result = render_inline(described_class.new(course))

expect(result.text).to include('You’ll be placed in schools for most of your course to get classroom experience. You will also spend time at a location where you will study.')
end
end

Expand Down Expand Up @@ -174,52 +179,4 @@
end
end
end

describe '#placements_url' do
context 'when course is published' do
it 'returns the find url' do
provider = build(:provider)
course = build(
:course,
:published,
provider:,
site_statuses: [
build(:site_status, :findable, site: build(:site))
]
).decorate

result = render_inline(described_class.new(course))

expect(result).to have_link(
'View list of school placements',
href: find_placements_path(course.provider_code, course.course_code)
)
end
end

context 'when course is not published' do
it 'returns the publish url' do
provider = create(:provider)
course = create(
:course,
provider:,
site_statuses: [
create(:site_status, :findable, site: create(:site))
]
).decorate

result = render_inline(described_class.new(course, preview: true))
url = placements_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)

expect(result).to have_link(
'View list of school placements',
href: url
)
end
end
end
end
6 changes: 3 additions & 3 deletions spec/components/find/courses/contents_component/view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

result = render_inline(described_class.new(course))

expect(result.text).to include('How school placements work')
expect(result.text).to include('Where you will train')
end
end

Expand All @@ -31,7 +31,7 @@

result = render_inline(described_class.new(course))

expect(result.text).to include('How school placements work')
expect(result.text).to include('Where you will train')
end
end

Expand All @@ -46,7 +46,7 @@

result = render_inline(described_class.new(course))

expect(result.text).not_to include('How school placements work')
expect(result.text).not_to include('Where you will train')
end
end

Expand Down
Loading

0 comments on commit 2e8eb75

Please sign in to comment.