Skip to content

Commit

Permalink
Move school placements into its own view
Browse files Browse the repository at this point in the history
Currently, school placements are listed on course pages, which can be
problematic for candidates as there is quite a lot of content on this
page.
We want to move this information to a separate page.
  • Loading branch information
CatalinVoineag committed Jul 3, 2024
1 parent edf18bc commit 3394c2b
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 17 deletions.
14 changes: 3 additions & 11 deletions app/components/find/courses/about_schools_component/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,11 @@
<%= course.placements_heading %>
</h3>

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

<p class="govuk-body">
We work with the following schools to provide your school placements.
<%= govuk_link_to(t(".view_list_of_school_placements"), placements_url) %>
</p>

<ul class="govuk-list govuk-list--spaced" id="course_school_placements">
<% course.preview_site_statuses.each do |site_status| %>
<li>
<strong><%= smart_quotes(site_status.site.location_name) %></strong>
<br>
<%= smart_quotes(site_status.site.decorate.full_address) %>
</li>
<% end %>
</ul>
<% end %>
</div>
</div>
15 changes: 15 additions & 0 deletions app/components/find/courses/about_schools_component/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ def show_scitt_guidance?
course_information_config.show_placement_guidance?(:program_type)
end

def placements_url
if course.has_unpublished_changes? || (course.is_published? && course.is_running?)
URI.join(
Settings.search_ui.base_url,
find_course_placements_path(course.provider_code, course.course_code)
).to_s
else
placements_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
end
end

private

def course_information_config
Expand Down
13 changes: 11 additions & 2 deletions app/controllers/find/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ class CoursesController < ApplicationController
include ApplyRedirect

before_action -> { render_not_found if provider.nil? }
before_action :set_course, only: %i[show placements]

before_action :render_feedback_component, only: :show

def show
render_not_found unless @course.is_published?
end

def placements
render_not_found unless @course.is_published?
end

private

def set_course
@course = provider.courses.includes(
:enrichments,
subjects: [:financial_incentive],
site_statuses: [:site]
).find_by!(course_code: params[:course_code]&.upcase).decorate

render_not_found unless @course.is_published?
end
end
end
5 changes: 5 additions & 0 deletions app/controllers/publish/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def show
flash.delete(:error_summary)
end

def placements
fetch_course
authorize @course
end

def details
fetch_course

Expand Down
1 change: 1 addition & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Course < ApplicationRecord
belongs_to :provider

delegate :tda_active?, to: :provider, allow_nil: true
delegate :provider_name, :provider_code, to: :provider, allow_nil: true

belongs_to :accrediting_provider,
->(c) { where(recruitment_cycle: c.recruitment_cycle) },
Expand Down
1 change: 1 addition & 0 deletions app/policies/course_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def can_update_funding_type?
end

alias preview? show?
alias placements? show?
alias apply? show?
alias details? show?
alias update? show?
Expand Down
21 changes: 21 additions & 0 deletions app/views/find/courses/placements.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%= content_for :page_title do %>
<%= t(
"find.courses.placements.heading",
provider_name: @course.provider_name
) %>
<% end %>
<% content_for :before_content do %>
<%= govuk_back_link(
href: search_ui_course_page_url(
provider_code: @course.provider_code,
course_code: @course.course_code
),
text: t(
"find.courses.placements.back",
course_name: @course.name,
course_code: @course.course_code
)
) %>
<% end %>

<%= render partial: "shared/courses/placements", locals: { course: @course } %>
22 changes: 22 additions & 0 deletions app/views/publish/courses/placements.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= content_for :page_title do %>
<%= t(
"publish.providers.courses.placements.heading",
provider_name: course.provider_name
) %>
<% end %>
<% content_for :before_content do %>
<%= govuk_back_link(
href: preview_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
),
text: t(
"publish.providers.courses.placements.back",
course_name: course.name,
course_code: course.course_code
)
) %>
<% end %>

<%= render partial: "shared/courses/placements", locals: { course: } %>
21 changes: 21 additions & 0 deletions app/views/shared/courses/_placements.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1 class="govuk-heading-xl">
<%= t(".heading", provider_name: course.provider_name) %>
</h1>

<%= govuk_warning_text(text: t(".warning")) %>

<p class="govuk-body">
<%= t(".will_place_you", provider_name: course.provider_name) %>
</p>

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

<ul class="govuk-list govuk-list--spaced" id="course_school_placements">
<% course.preview_site_statuses.each do |site_status| %>
<li>
<strong><%= smart_quotes(site_status.site.location_name) %></strong>
<br>
<%= smart_quotes(site_status.site.decorate.full_address) %>
</li>
<% end %>
</ul>
10 changes: 10 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
en:
shared:
courses:
placements:
heading: School placements at %{provider_name}
warning: You can’t pick which schools you will be in.
will_place_you: '%{provider_name} will place you in different schools you can travel to during your training.'
schools_to_be_placed: 'The schools you could be placed in are:'
markdown_formatting:
summary_text: Help formatting your text
title: How to format your text
Expand Down Expand Up @@ -389,6 +396,9 @@ en:
publish:
providers:
courses:
placements:
heading: School placements at %{provider_name}
back: Back to %{course_name} (%{course_code})
description_content:
course_information_heading: Course information
about_course_label: About this course
Expand Down
7 changes: 7 additions & 0 deletions config/locales/find.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ en:
primary_title: Primary courses with subject specialisms
secondary_title: Which secondary subjects do you want to teach?
courses:
about_schools_component:
view:
view_list_of_school_placements: View list of school placements
work_with_schools: We work with the following schools to provide your school placements.
placements:
heading: School placements at %{provider_name}
back: Back to %{course_name} (%{course_code})
show:
back_to_search: Back to search results
scholarships:
Expand Down
1 change: 1 addition & 0 deletions config/routes/find.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
get '/privacy', to: 'pages#privacy', as: :privacy
get '/terms-conditions', to: 'pages#terms', as: :terms
get '/course/:provider_code/:course_code', to: 'courses#show', as: 'course'
get '/placements/:provider_code/:course_code', to: 'courses#placements', as: 'course_placements'
get '/course/:provider_code/:course_code/apply', to: 'courses#apply', as: :apply
get '/results', to: 'results#index', as: 'results'
get '/location-suggestions', to: 'location_suggestions#index'
Expand Down
1 change: 1 addition & 0 deletions config/routes/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
end

resources :courses, param: :code, only: %i[index new create show] do
get '/placements', on: :member, to: 'courses#placements', as: 'placements'
get '/apply', on: :member, to: 'courses#apply', as: :apply
get '/details', on: :member, to: 'courses#details'

Expand Down
54 changes: 54 additions & 0 deletions spec/components/find/courses/about_schools_component/view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'rails_helper'

describe Find::Courses::AboutSchoolsComponent::View, type: :component do
include Rails.application.routes.url_helpers

context 'valid program_type' do
it 'renders the component' do
%w[higher_education_programme scitt_programme].each do |program_type|
Expand Down Expand Up @@ -172,4 +174,56 @@
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))
url = URI.join(
Settings.search_ui.base_url,
find_course_placements_path(course.provider_code, course.course_code)
).to_s

expect(result).to have_link(
'View list of school placements',
href: url
)
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))
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
27 changes: 27 additions & 0 deletions spec/controllers/find/courses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,32 @@ module Find
expect(response).to render_template('errors/not_found')
end
end

describe '#placements' do
context 'when provider is not pressent' do
it 'renders the not found page' do
get :placements, params: {
provider_code: 'ABC',
course_code: '123'
}

expect(response).to render_template('errors/not_found')
end
end

context 'when course is not published' do
it 'renders the not found page' do
provider = create(:provider)
course = create(:course, provider:)

get :placements, params: {
provider_code: provider.provider_code,
course_code: course.course_code
}

expect(response).to render_template('errors/not_found')
end
end
end
end
end
21 changes: 18 additions & 3 deletions spec/features/find/search/viewing_a_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
end
end

scenario 'user views school placements' do
given_there_is_a_findable_course
when_i_visit_the_course_page
when_i_click('View list of school placements')
then_i_should_be_on_the_school_placements_page
end

private

def given_there_is_a_findable_course
Expand Down Expand Up @@ -280,9 +287,7 @@ def then_i_should_see_the_course_information

expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies')

@course.site_statuses.new_or_running.map(&:site).uniq.each do |site|
expect(find_course_show_page).to have_content(smart_quotes(site.decorate.full_address))
end
expect(find_course_show_page).to have_link('View list of school placements')

expect(find_course_show_page).to have_course_advice

Expand Down Expand Up @@ -345,4 +350,14 @@ def accrediting_provider
provider_name: 'Accrediting Provider 1'
)
end

def when_i_click(button)
click_on(button)
end

def then_i_should_be_on_the_school_placements_page
@course.site_statuses.new_or_running.map(&:site).uniq.each do |site|
expect(find_course_show_page).to have_content(smart_quotes(site.decorate.full_address))
end
end
end
17 changes: 16 additions & 1 deletion spec/features/publish/viewing_a_course_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@
end
end

scenario 'user views school placements' do
given_i_am_authenticated(user: user_with_fee_based_course)
when_i_visit_the_publish_course_preview_page
when_i_click('View list of school placements')
then_i_should_be_on_the_school_placements_page
end

private

def then_i_see_custom_address
Expand Down Expand Up @@ -272,7 +279,7 @@ def then_i_see_the_course_preview_details
)

expect(publish_course_preview_page).to have_study_sites_table
expect(publish_course_preview_page).to have_school_placements_table
expect(publish_course_preview_page).to have_link('View list of school placements')

expect(publish_course_preview_page).to have_course_advice

Expand Down Expand Up @@ -475,4 +482,12 @@ def and_i_do_not_see_financial_support
expect(publish_course_preview_page).not_to have_scholarship_amount
expect(publish_course_preview_page).not_to have_bursary_amount
end

def when_i_click(button)
click_on(button)
end

def then_i_should_be_on_the_school_placements_page
expect(publish_course_preview_page).to have_school_placements_table
end
end
Loading

0 comments on commit 3394c2b

Please sign in to comment.