Skip to content

Commit

Permalink
Training with disabilities view on courses
Browse files Browse the repository at this point in the history
The course show page on find and the preview page on publish contains
too much information that might be off-putting for the user.

This commit tries to fix this by putting this section into its own view
accessible from the course page
  • Loading branch information
CatalinVoineag committed Jul 10, 2024
1 parent ffd59fa commit 347fce8
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def degree_link = degrees_start_publish_provider_recruitment_cycle_course_path(p
def fee_uk_eu_link = fees_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
def gcse_link = gcses_pending_or_equivalency_tests_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
def how_school_placements_work_link = school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
def train_with_disability_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true, anchor: 'train-with-disability')
def train_with_disability_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true, anchor: 'train-with-disability')
def train_with_us_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true, anchor: 'train-with-us')

def about_accrediting_provider_link
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Find
module Courses
class TrainingWithDisabilitiesController < Find::ApplicationController
before_action -> { render_not_found if provider.nil? }
before_action -> { render_not_found if provider.train_with_disability.blank? }

def show
@course = provider.courses.includes(
:enrichments,
subjects: [:financial_incentive],
site_statuses: [:site]
).find_by!(course_code: params[:course_code]&.upcase).decorate
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Publish
module Courses
class TrainingWithDisabilitiesController < PublishController
include CourseBasicDetailConcern
before_action :build_course, only: %i[show]

def show; end

private

def build_course
super
authorize @course
end
end
end
end
4 changes: 2 additions & 2 deletions app/helpers/find/goto_preview_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def goto_provider_value(param_form_key:, params:)
params[:goto_provider] || params.dig(param_form_key, :goto_provider)
end

def goto_provider?(param_form_key:, params:)
goto_provider_value(param_form_key:, params:) == 'true'
def goto_training_with_disabilities_value(param_form_key:, params:)
params[:goto_training_with_disabilities] || params.dig(param_form_key, :goto_training_with_disabilities)
end

def back_link_path(param_form_key:, params:, provider_code:, recruitment_cycle_year:, course_code:)
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/preview_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module PreviewHelper
def preview?(params)
params[:action] == 'preview' ||
params[:action].nil? ||
(params[:controller] == 'publish/courses/providers' && params[:action] == 'show')
(params[:controller] == 'publish/courses/providers' && params[:action] == 'show') ||
(params[:controller] == 'publish/courses/training_with_disabilities' && params[:action] == 'show')
end
end
16 changes: 7 additions & 9 deletions app/views/find/courses/_train_with_disabilities.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<div class="govuk-!-margin-bottom-8">
<h2 class="govuk-heading-l" id="section-train-with-disabilities">Training with disabilities and other needs</h2>
<div data-qa="course__train_with_disabilities">
<% if course.provider.train_with_disability.present? %>
<%= markdown(course.provider.train_with_disability) %>
<% else %>
<%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :train_with_disability, is_preview: preview?(params)) %>
<% end %>
</div>
<h1 class="govuk-heading-xl" id="section-train-with-disabilities">Training with disabilities and other needs</h1>
<div data-qa="course__train_with_disabilities">
<% if course.provider.train_with_disability.present? %>
<%= markdown(course.provider.train_with_disability) %>
<% else %>
<%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :train_with_disability, is_preview: preview?(params)) %>
<% end %>
</div>
14 changes: 13 additions & 1 deletion app/views/find/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@
<%= render Find::Courses::InternationalStudentsComponent::View.new(course: @course) %>

<% if @provider.train_with_disability.present? %>
<%= render partial: "find/courses/train_with_disabilities", locals: { course: @course } %>
<h2 class="govuk-heading-l" id="section-train-with-disabilities">
<%= t(".training_with_disabilities") %>
</h2>

<p class="govuk-body">
<%= govuk_link_to(
t(".training_with_disabilities_link", provider_name: @course.provider_name),
find_training_with_disabilities_path(
@course.provider_code,
@course.course_code
)
) %>
</p>
<% end %>

<%= render partial: "find/courses/advice", locals: { course: @course } %>
Expand Down
29 changes: 29 additions & 0 deletions app/views/find/courses/training_with_disabilities/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%= content_for :page_title do %>
<%= t(".heading") %>
<% 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(
".back",
course_name: @course.name,
course_code: @course.course_code
)
) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: "find/courses/train_with_disabilities", locals: { course: @course } %>

<p class="govuk-body">
<%= govuk_link_to(
t(".contact", provider_name: @course.provider_name),
find_provider_path(@course.provider_code, @course.course_code)
) %>
</p>
</div>
</div>
15 changes: 14 additions & 1 deletion app/views/publish/courses/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@

<%= render Find::Courses::InternationalStudentsComponent::View.new(course:) %>

<%= render partial: "find/courses/train_with_disabilities", locals: { course: } %>
<h2 class="govuk-heading-l" id="section-train-with-disabilities">
<%= t(".training_with_disabilities") %>
</h2>

<p class="govuk-body">
<%= govuk_link_to(
t(".training_with_disabilities_link", provider_name: course.provider_name),
training_with_disabilities_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
) %>
</p>

<%= render partial: "find/courses/advice", locals: { course: } %>

Expand Down
34 changes: 34 additions & 0 deletions app/views/publish/courses/training_with_disabilities/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<%= content_for :page_title do %>
<%= t(".heading") %>
<% 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(
".back",
course_name: @course.name,
course_code: @course.course_code
)
) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: "find/courses/train_with_disabilities", locals: { course: } %>

<p class="govuk-body">
<%= govuk_link_to(
t(".contact", provider_name: @course.provider_name),
provider_publish_provider_recruitment_cycle_course_path(
@course.provider_code,
@course.recruitment_cycle_year,
@course.course_code
)
) %>
</p>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/publish/providers/about.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
rows: 15) %>
<%= f.hidden_field(:goto_preview, value: goto_preview_value(param_form_key: f.object_name.to_sym, params:)) %>
<%= f.hidden_field(:goto_provider, value: goto_provider_value(param_form_key: f.object_name.to_sym, params:)) %>
<%= f.hidden_field(:goto_training_with_disabilities, value: goto_training_with_disabilities_value(param_form_key: f.object_name.to_sym, params:)) %>
<%= f.hidden_field(:course_code, value: params[:course_code] || params.dig(f.object_name.to_sym, :course_code)) %>

<%= f.govuk_submit "Save and publish" %>
Expand Down
9 changes: 9 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ en:
add: "Add user"
update: "Update user"
publish:
courses:
training_with_disabilities:
show:
heading: Training with disabilities and other needs
back: Back to %{course_name} (%{course_code})
contact: Contact %{provider_name}
preview:
training_with_disabilities: Training with disabilities and other needs
training_with_disabilities_link: Find out about training with disabilities and other needs at %{provider_name}
providers:
courses:
accredited_provider:
Expand Down
7 changes: 7 additions & 0 deletions config/locales/find.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ en:
telephone: Telephone
school_website: School Website
address: Address
training_with_disabilities:
show:
heading: Training with disabilities and other needs
back: Back to %{course_name} (%{course_code})
contact: Contact %{provider_name}
about_schools_component:
view:
view_list_of_school_placements: View list of school placements
Expand All @@ -118,6 +123,8 @@ en:
not_consider_a_level_equivalency: We will not consider candidates who need to take A level equivalency tests.
show:
back_to_search: Back to search results
training_with_disabilities: Training with disabilities and other needs
training_with_disabilities_link: Find out about training with disabilities and other needs at %{provider_name}
scholarships:
physics:
body: Institute of Physics
Expand Down
1 change: 1 addition & 0 deletions config/routes/find.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
scope module: :courses, path: '/courses' do
get '/:provider_code/:course_code/provider', to: 'providers#show', as: :provider
get '/:provider_code/:course_code/accredited-by', to: 'accrediting_providers#show', as: :accrediting_provider
get '/:provider_code/:course_code/training-with-disabilities', to: 'training_with_disabilities#show', as: :training_with_disabilities
end

get '/feature-flags', to: 'feature_flags#index'
Expand Down
2 changes: 2 additions & 0 deletions config/routes/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@
get '/study-sites', on: :member, to: 'courses/study_sites#edit'
put '/study-sites', on: :member, to: 'courses/study_sites#update'

get '/training-with-disabilities', on: :member, to: 'courses/training_with_disabilities#show'

get '/applications-open', on: :member, to: 'courses/applications_open#edit'
put '/applications-open', on: :member, to: 'courses/applications_open#update'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module CoursePreview
how_school_placements_work:
school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true),
train_with_disability:
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-disability",
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true)}#train-with-disability",
train_with_us:
"#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true)}#train-with-us",
about_accrediting_provider:
Expand Down
25 changes: 23 additions & 2 deletions spec/features/find/search/viewing_a_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

feature 'Viewing a findable course' do
include PublishHelper
include Rails.application.routes.url_helpers

before do
Timecop.travel(Find::CycleTimetable.mid_cycle)
Expand Down Expand Up @@ -89,6 +90,15 @@
then_i_should_be_on_the_course_page
end

scenario 'user views the training with disabilities page' do
given_there_is_a_findable_course
when_i_visit_the_course_page
when_i_click("Find out about training with disabilities and other needs at #{@course.provider_name}")
then_i_should_be_on_the_training_with_disabilities_page
when_i_click("Back to #{@course.name} (#{course.course_code})")
then_i_should_be_on_the_course_page
end

private

def given_there_is_a_findable_course
Expand Down Expand Up @@ -259,8 +269,8 @@ def then_i_should_see_the_course_information
'Certificate must be print in blue ink'
)

expect(find_course_show_page.train_with_disability).to have_content(
provider.train_with_disability
expect(find_course_show_page).to have_content(
'Training with disabilities and other needs'
)

expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies')
Expand Down Expand Up @@ -379,4 +389,15 @@ def then_i_should_be_on_the_course_page
).to_s
)
end

def then_i_should_be_on_the_training_with_disabilities_page
expect(find_course_show_page.train_with_disability).to have_content(
provider.train_with_disability
)

expect(page).to have_link(
"Contact #{course.provider_name}",
href: find_provider_path(@course.provider_code, @course.course_code)
)
end
end
27 changes: 23 additions & 4 deletions spec/features/publish/viewing_a_course_preview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'rails_helper'

feature 'Course show', { can_edit_current_and_next_cycles: false } do
include Rails.application.routes.url_helpers
context 'bursaries and scholarships is announced' do
before do
FeatureFlag.activate(:bursaries_and_scholarships_announced)
Expand Down Expand Up @@ -37,14 +38,17 @@
scenario 'blank training with disabilities and other needs' do
given_i_am_authenticated(user: user_with_no_course_enrichments)
when_i_visit_the_publish_course_preview_page
and_i_click_link_or_button("Find out about training with disabilities and other needs at #{@course.provider_name}")
and_i_click_link_or_button('Enter details about training with disabilities and other needs')
then_i_should_be_on_about_your_organisation_page
and_i_click_link_or_button('Back')
then_i_should_be_back_on_the_preview_page
then_i_should_be_on_the_training_with_disabilities_page
and_i_click_link_or_button('Enter details about training with disabilities and other needs')
and_i_submit_a_valid_about_your_organisation
then_i_should_be_back_on_the_preview_page
then_i_should_be_on_the_training_with_disabilities_page
then_i_should_see_the_updated_content('test training with disabilities')
and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})")
then_i_should_be_back_on_the_preview_page
end

scenario 'blank school placements section' do
Expand Down Expand Up @@ -239,8 +243,8 @@ def then_i_see_the_course_preview_details
'Financial support from the training provider'
)

expect(publish_course_preview_page.train_with_disability).to have_content(
provider.train_with_disability
expect(publish_course_preview_page).to have_content(
'Training with disabilities and other needs'
)

expect(publish_course_preview_page).to have_content '2:1 or above, or equivalent'
Expand Down Expand Up @@ -504,4 +508,19 @@ def then_i_should_be_on_the_accrediting_provider_page
decorated_course.about_accrediting_provider
)
end

def then_i_should_be_on_the_training_with_disabilities_page
expect(publish_course_preview_page.train_with_disability).to have_content(
provider.train_with_disability
)

expect(page).to have_link(
"Contact #{course.provider_name}",
href: provider_publish_provider_recruitment_cycle_course_path(
@course.provider_code,
@course.recruitment_cycle_year,
@course.course_code
)
)
end
end

0 comments on commit 347fce8

Please sign in to comment.