Skip to content

Commit

Permalink
Merge pull request #4262 from DFE-Digital/1638-publish-amends-to-cour…
Browse files Browse the repository at this point in the history
…se-description-tab

[1638] publish amends to course description tab
  • Loading branch information
elceebee authored Jun 7, 2024
2 parents 0807880 + 5a4d2a8 commit 0bc6fc3
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 109 deletions.
8 changes: 7 additions & 1 deletion app/decorators/course_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ def subject_present?(subject_to_find)
end

def placements_heading
CourseEnrichment.human_attribute_name("how_school_placements_work#{further_education? ? '/further_education' : nil}")
CourseEnrichment.human_attribute_name('how_school_placements_work')
end

def length_and_fees_or_salary_heading
heading = has_fees? ? 'course_length_and_fees_heading' : 'course_length_and_salary_heading'

I18n.t("publish.providers.courses.description_content.#{heading}")
end

def further_education?
Expand Down
8 changes: 3 additions & 5 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def enrichment_error_link(model, field, error)
end

# TODO: refactor enrichment_summary method to not use an instance variable
def enrichment_summary(summary_list, model, key, value, fields, truncate_value: true, action_path: nil, action_visually_hidden_text: nil)
action = render_action(action_path, action_visually_hidden_text)
def enrichment_summary(summary_list, model, key, value, fields, action_path: nil, action_visually_hidden_text: nil)
action = render_action(action_path, action_visually_hidden_text || key.downcase)

if fields.any? { |field| @errors&.key? field.to_sym }
errors = fields.map do |field|
Expand All @@ -47,15 +47,13 @@ def enrichment_summary(summary_list, model, key, value, fields, truncate_value:

value = raw(*errors)
action = nil
elsif truncate_value
classes = 'app-summary-list__value--truncate'
end

value = raw('<span class="app-!-colour-muted">Empty</span>') if value.blank?

summary_list.with_row(html_attributes: { data: { qa: "enrichment__#{fields.first}" } }) do |row|
row.with_key { key.html_safe }
row.with_value(classes: classes || ['govuk-summary-list__value']) { value }
row.with_value(classes: ['govuk-summary-list__value']) { value }
if action
row.with_action(**action)
else
Expand Down
2 changes: 1 addition & 1 deletion app/services/courses/copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Copy
].freeze

SCHOOL_PLACEMENTS_FIELDS = [
['How school placements work', 'how_school_placements_work']
['How placements work', 'how_school_placements_work']
].freeze

FEES_FIELDS = [
Expand Down
109 changes: 50 additions & 59 deletions app/views/publish/courses/_description_content.html.erb
Original file line number Diff line number Diff line change
@@ -1,170 +1,161 @@
<h2 class="govuk-heading-m">Course information</h2>
<h2 class="govuk-heading-m">
<%= t("publish.providers.courses.description_content.course_information_heading") %>
</h2>

<%= govuk_summary_list do |summary_list| %>
<% enrichment_summary(
summary_list,
:course,
"About this course",
t("publish.providers.courses.description_content.about_course_label"),
value_provided?(course.about_course),
%w[about_course],
action_path: course.is_withdrawn? ? nil : about_this_course_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "details about this course"
action_visually_hidden_text: t("publish.providers.courses.description_content.about_course_hidden_text")
) %>

<% enrichment_summary(
summary_list,
:course,
t("publish.providers.courses.description_content.how_school_placements_work_label"),
value_provided?(course.how_school_placements_work),
%w[how_school_placements_work],
action_path: course.is_withdrawn? ? nil : school_placements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: t("publish.providers.courses.description_content.how_school_placements_work_hidden_text")
) %>

<% enrichment_summary(
summary_list,
:course,
"Interview process",
t("publish.providers.courses.description_content.interview_process_label"),
value_provided?(course.interview_process),
%w[interview_process],
action_path: course.is_withdrawn? ? nil : interview_process_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "details about the interview process"
action_visually_hidden_text: t("publish.providers.courses.description_content.interview_process_hidden_text")
) %>

<% enrichment_summary(
summary_list,
:course,
course.placements_heading,
value_provided?(course.how_school_placements_work),
%w[how_school_placements_work],
action_path: course.is_withdrawn? ? nil : school_placements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "details about how school placements work"
) %>
<% end %>

<h2 class="govuk-heading-m">
<% if course.has_fees? %>
Course length and fees
<% else %>
Course length and salary
<% end %>
</h2>
<h2 class="govuk-heading-m"><%= course.length_and_fees_or_salary_heading %></h2>

<%= govuk_summary_list do |summary_list| %>
<% if course.has_fees? %>
<% enrichment_summary(
summary_list,
:course,
"Course length",
t("publish.providers.courses.description_content.course_length_label"),
value_provided?(course.length),
%w[course_length],
action_path: course.cannot_change_course_length? ? nil : length_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "course length"
action_path: course.cannot_change_course_length? ? nil : length_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)
) %>

<% enrichment_summary(
summary_list,
:course,
"Fee for UK students",
t("publish.providers.courses.description_content.fee_for_uk_students_label"),
value_provided?(number_to_currency(course.fee_uk_eu)),
%w[fee_uk_eu],
action_path: course.is_withdrawn? ? nil : fees_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "fee for UK students"
action_visually_hidden_text: t("publish.providers.courses.description_content.fee_for_uk_students_hidden_text")
) %>

<% enrichment_summary(
summary_list,
:course,
"Fee for international students",
t("publish.providers.courses.description_content.fee_for_international_students_label"),
value_provided?(number_to_currency(course.fee_international)),
%w[fee_international],
action_path: course.is_withdrawn? ? nil : fees_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "fee for international students"
action_path: course.is_withdrawn? ? nil : fees_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)
) %>

<% enrichment_summary(
summary_list,
:course,
CourseEnrichment.human_attribute_name("fee_details"),
t("publish.providers.courses.description_content.fee_details_label"),
value_provided?(course.fee_details),
%w[fee_details],
action_path: course.is_withdrawn? ? nil : fees_and_financial_support_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: CourseEnrichment.human_attribute_name("fee_details")
action_visually_hidden_text: t("publish.providers.courses.description_content.fee_details_hidden_text")
) %>

<% if course.financial_support.present? %>
<% enrichment_summary(
summary_list,
:course,
"Financial support you offer",
t("publish.providers.courses.description_content.financial_support_you_offer_label"),
value_provided?(course.financial_support),
%w[financial_support]
) %>
<% end %>

<% summary_list.with_row(html_attributes: { data: { qa: "course__financial_incentives" } }) do |row| %>
<% row.with_key { "Financial support from the government" } %>
<% row.with_key { t("publish.providers.courses.description_content.financial_incentive_details_label") } %>
<% row.with_value { course.financial_incentive_details } %>
<% row.with_action %>
<% end %>
<% else %>
<% enrichment_summary(
summary_list,
:course,
"Course length",
value_provided?(course.length),
%w[course_length],
action_path: course.cannot_change_course_length? ? nil : length_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "course length"
) %>
summary_list,
:course,
t("publish.providers.courses.description_content.course_length_label"),
value_provided?(course.length),
%w[course_length],
action_path: course.cannot_change_course_length? ? nil : length_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: t("publish.providers.courses.description_content.course_length_hidden_text")
) %>

<% enrichment_summary(
summary_list,
:course,
"Salary",
t("publish.providers.courses.description_content.salary_label"),
value_provided?(course.salary_details),
%w[salary_details],
action_path: course.is_withdrawn? ? nil : salary_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "salary"
action_path: course.is_withdrawn? ? nil : salary_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)
) %>
<% end %>
<% end %>

<h2 class="govuk-heading-m">Requirements and eligibility</h2>
<h2 class="govuk-heading-m">
<%= t("publish.providers.courses.description_content.requirements_heading") %>
</h2>

<%= govuk_summary_list do |summary_list| %>
<% if course.show_degree_requirements_row? %>
<% enrichment_summary(
summary_list,
:course,
"Degree",
t("publish.providers.courses.description_content.degree_label"),
(render DegreeRowContent.new(course:, errors: @errors)),
%w[degree_grade degree_subject_requirements],
truncate_value: false,
action_path: !course.is_withdrawn? && course.degree_section_complete? ? degrees_start_publish_provider_recruitment_cycle_course_path(@provider.provider_code, @provider.recruitment_cycle_year, course.course_code) : nil,
action_visually_hidden_text: "degree"
action_path: !course.is_withdrawn? && course.degree_section_complete? ? degrees_start_publish_provider_recruitment_cycle_course_path(@provider.provider_code, @provider.recruitment_cycle_year, course.course_code) : nil
) %>
<% end %>

<% enrichment_summary(
summary_list,
:course,
"GCSEs",
t("publish.providers.courses.description_content.gcse_label"),
(render GcseRowContent.new(course:, errors: @errors)),
%w[accept_pending_gcse accept_gcse_equivalency accept_english_gcse_equivalency accept_maths_gcse_equivalency accept_science_gcse_equivalency additional_gcse_equivalencies],
truncate_value: false,
action_path: !course.is_withdrawn? && course.gcse_section_complete? ? gcses_pending_or_equivalency_tests_publish_provider_recruitment_cycle_course_path(@provider.provider_code, @provider.recruitment_cycle_year, course.course_code) : nil,
action_visually_hidden_text: "GCSEs"
action_path: !course.is_withdrawn? && course.gcse_section_complete? ? gcses_pending_or_equivalency_tests_publish_provider_recruitment_cycle_course_path(@provider.provider_code, @provider.recruitment_cycle_year, course.course_code) : nil
) %>

<% unless @hide_other_requirements %>
<% enrichment_summary(
summary_list,
:course,
"Personal qualities",
t("publish.providers.courses.description_content.personal_qualities_label"),
value_provided?(course.personal_qualities),
%w[personal_qualities],
action_path: course.is_withdrawn? ? nil : "#{requirements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)}#personal-qualities",
action_visually_hidden_text: "personal qualities"
action_path: course.is_withdrawn? ? nil : "#{requirements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)}#personal-qualities"
) %>

<% enrichment_summary(
summary_list,
:course,
"Other requirements",
t("publish.providers.courses.description_content.other_requirements_label"),
value_provided?(course.other_requirements),
%w[other_requirements],
action_path: course.is_withdrawn? ? nil : "#{requirements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)}#other-requirements",
action_visually_hidden_text: "other requirements"
action_path: course.is_withdrawn? ? nil : "#{requirements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)}#other-requirements"
) %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/publish/courses/details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<%= render partial: "publish/courses/course_navigation" %>

<section class="app-section" id="basic_details" role="tabpanel" aria-labelledby="basic_details_tab">
<section class="app-section" id="basic_details">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: "basic_details_tab" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/publish/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<section class="app-section" id="description">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-column-full">
<%= render partial: "description_content" %>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions app/views/publish/providers/details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"Student visas",
student_visa_sponsorship_status(@provider),
%w[can_sponsor_student_visa],
truncate_value: false,
action_path: @provider.university? ? student_visa_publish_provider_recruitment_cycle_path(@provider.provider_code, @provider.recruitment_cycle_year) : nil,
action_visually_hidden_text: "if candidates can get Student visa sponsorship"
) %>
Expand All @@ -70,7 +69,6 @@
"Skilled Worker visas",
skilled_worker_visa_sponsorship_status(@provider),
%w[can_sponsor_skilled_worker_visa],
truncate_value: false,
action_path: skilled_worker_visa_publish_provider_recruitment_cycle_path(@provider.provider_code, @provider.recruitment_cycle_year),
action_visually_hidden_text: "if candidates can get Skilled Worker visa sponsorship"
) %>
Expand Down
40 changes: 33 additions & 7 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ en:
gcse:
text: "Enter GCSE and equivalency test requirements"
how_school_placements_work:
text: "Enter details about how school placements work"
text: "Enter details about how placements work"
train_with_disability:
text: "Enter details about training with disabilities and other needs"
train_with_us:
Expand Down Expand Up @@ -296,6 +296,31 @@ en:
update: "Update user"
publish:
providers:
courses:
description_content:
course_information_heading: Course information
about_course_label: About this course
about_course_hidden_text: details about this course
interview_process_label: Interview process (optional)
interview_process_hidden_text: details about the interview process
how_school_placements_work_label: How placements work
how_school_placements_work_hidden_text: details about how placements work
course_length_and_fees_heading: Course length and fees
course_length_and_salary_heading: Course length and salary
course_length_label: Course length
fee_for_uk_students_label: Fee for UK students
fee_for_uk_students_hidden_text: fee for UK students
fee_for_international_students_label: Fee for international students
fee_details_label: Fees and financial support (optional)
fee_details_hidden_text: fees and financial support
financial_support_you_offer_label: Financial support you offer
financial_incentive_details_label: Financial support from the government
salary_label: Salary
requirements_heading: Requirements and eligibility
degree_label: Degree
gcse_label: GCSEs
personal_qualities_label: Personal qualities
other_requirements_label: Other requirements
course_length:
edit:
course_length: Course length
Expand Down Expand Up @@ -351,8 +376,8 @@ en:
</ul>
school_placements:
edit:
page_title: How school placements work - %{course_name_and_code}
submit_button: Update how school placements work
page_title: How placements work - %{course_name_and_code}
submit_button: Update how placements work
guidance_text_html:
<p class="govuk-body">Give candidates information about the schools they will be training in</p>
<p class="govuk-body">Tell them:</p>
Expand Down Expand Up @@ -564,8 +589,9 @@ en:
course_enrichment:
fee_uk_eu: "Course fees for UK and EU students"
fee_international: "Course fees for international students"
how_school_placements_work/further_education: Teaching placements
how_school_placements_work: How placements work
fee_details: Fees and financial support
about_course: About this course
site:
location_name: "Name"
address1: "Building and street"
Expand Down Expand Up @@ -665,7 +691,7 @@ en:
about_course:
blank: "^Enter information about this course"
how_school_placements_work:
blank: "^Enter details about how school placements work"
blank: "^Enter details about how placements work"
required_qualifications:
blank: "^Enter details about the qualifications needed"
course_length:
Expand Down Expand Up @@ -913,8 +939,8 @@ en:
publish/course_school_placements_form:
attributes:
how_school_placements_work:
blank: Enter details about how school placements work
too_long: Reduce the word count for how school placements work
blank: Enter details about how placements work
too_long: Reduce the word count for how placements work
publish/course_fees_and_financial_support_form:
attributes:
fee_details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module CoursePreview
include_examples 'course with missing information', :degree, 'Enter degree requirements'
include_examples 'course with missing information', :fee_uk_eu, 'Enter details about fees and financial support'
include_examples 'course with missing information', :gcse, 'Enter GCSE and equivalency test requirements'
include_examples 'course with missing information', :how_school_placements_work, 'Enter details about how school placements work'
include_examples 'course with missing information', :how_school_placements_work, 'Enter details about how placements work'
include_examples 'course with missing information', :train_with_disability, 'Enter details about training with disabilities and other needs'
include_examples 'course with missing information', :train_with_us, 'Enter details about the training provider'
include_examples 'course with missing information', :about_accrediting_provider, 'Enter details about the accredited provider'
Expand Down
Loading

0 comments on commit 0bc6fc3

Please sign in to comment.