diff --git a/app/components/a_level_row_component.html.erb b/app/components/a_level_row_component.html.erb index ec0b60cd61..001b6f9857 100644 --- a/app/components/a_level_row_component.html.erb +++ b/app/components/a_level_row_component.html.erb @@ -1,7 +1,32 @@ <% if course.a_levels_requirements_answered? %> -

- <%= a_level_requirement_content %> -

+ <% if @course.a_level_requirements.present? %> + <% Array(@course.a_level_subject_requirements).map do |a_level_subject_requirement| %> +

+ <%= a_level_subject_row_content(a_level_subject_requirement.with_indifferent_access) %> +

+ <% end %> + + <% unless @course.accept_pending_a_level.nil? %> +

+ <%= pending_a_level_summary_content %> +

+ <% end %> + + <% unless @course.accept_a_level_equivalency.nil? %> +

+ <%= a_level_equivalency_summary_content %> +

+ <% end %> + + <% if @course.accept_a_level_equivalency? && @course.additional_a_level_equivalencies.present? %> +

+ <%= @course.additional_a_level_equivalencies %> +

+ <% end %> + <% else %> + <%= a_level_not_required_content %> + <% end %> + <% else %> <%= govuk_inset_text(classes: inset_text_css_classes) do %>

<%= t("publish.providers.courses.description_content.a_levels_heading") %>

diff --git a/app/components/a_level_row_component.rb b/app/components/a_level_row_component.rb index be8a988139..4a20116d88 100644 --- a/app/components/a_level_row_component.rb +++ b/app/components/a_level_row_component.rb @@ -9,12 +9,31 @@ def initialize(course:, errors: nil) @errors = errors&.values&.flatten end - def a_level_requirement_content - return if @course.a_level_requirements.present? - + def a_level_not_required_content I18n.t('publish.providers.courses.description_content.a_levels_not_required') end + def a_level_subject_row_content(a_level_subject_requirement) + row_value = ALevelSubjectRequirementRowComponent.new(a_level_subject_requirement).row_value + + if @course.accept_a_level_equivalency? + [ + row_value, + I18n.t('course.a_level_equivalencies.suffix') + ].join(', ') + else + row_value + end + end + + def pending_a_level_summary_content + I18n.t("course.consider_pending_a_level.row.#{@course.accept_pending_a_level?}") unless @course.accept_pending_a_level.nil? + end + + def a_level_equivalency_summary_content + I18n.t("course.a_level_equivalencies.row.#{@course.accept_a_level_equivalency?}") unless @course.accept_a_level_equivalency.nil? + end + def inset_text_css_classes 'app-inset-text--narrow-border app-inset-text--important' end diff --git a/config/locales/en.yml b/config/locales/en.yml index 198e865f95..0c10488cd6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -327,10 +327,17 @@ en: consider_pending_a_level: heading: Will you consider candidates with pending A levels? hint: These are candidates who expect to have the qualification before the beginning of the course. You can give them an offer, on the condition that they pass their A levels. + row: + "true": "Candidates with pending A levels will be considered." + "false": "Candidates with pending A levels will not be considered." a_level_equivalencies: heading: Will you consider candidates who need to take an equivalency test for their A levels? submit: Update A levels hint: For example, if you offer the tests or ask candidates to use a third party, and if there are any costs to pay + suffix: or equivalent qualification + row: + "true": "Equivalency tests will be considered." + "false": "Equivalency tests will not be considered." new: level: special_educational_needs_and_disabilities: diff --git a/spec/components/a_level_row_component_spec.rb b/spec/components/a_level_row_component_spec.rb new file mode 100644 index 0000000000..df36bb97c2 --- /dev/null +++ b/spec/components/a_level_row_component_spec.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ALevelRowComponent do + it 'renders the a_level_not_required_content when a level requirements are not present' do + course = create(:course, a_level_requirements: false) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include(I18n.t('publish.providers.courses.description_content.a_levels_not_required')) + end + + it 'renders the a_level_subject_row_content when a level requirements and subject requirements are present' do + a_level_subject_requirement = { 'subject' => 'other_subject', 'other_subject' => 'Math', 'minimum_grade_required' => 'A' } + course = create(:course, a_level_requirements: true, a_level_subject_requirements: [a_level_subject_requirement]) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include('Math - Grade A or above') + end + + it 'renders the pending a level summary content for acceptance when course accepts pending a levels' do + course = create(:course, accept_pending_a_level: true, a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include(I18n.t('course.consider_pending_a_level.row.true')) + end + + it 'renders the pending a level summary content for non-acceptance when course does not accept pending a levels' do + course = create(:course, accept_pending_a_level: false, a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include(I18n.t('course.consider_pending_a_level.row.false')) + end + + it 'renders the a level equivalency summary content for acceptance when course accepts a level equivalencies' do + course = create(:course, accept_a_level_equivalency: true, a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include(I18n.t('course.a_level_equivalencies.row.true')) + end + + it 'renders the a level equivalency summary content for non-acceptance when course does not accept a level equivalencies' do + course = create(:course, accept_a_level_equivalency: false, a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include(I18n.t('course.a_level_equivalencies.row.false')) + end + + it 'renders the additional a level equivalencies content when present' do + course = create(:course, accept_a_level_equivalency: true, additional_a_level_equivalencies: 'Some additional information', a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).to include('Some additional information') + end + + it 'does not render the additional a level equivalencies when no equivalencies' do + course = create(:course, accept_a_level_equivalency: false, additional_a_level_equivalencies: 'Some additional information', a_level_requirements: true) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).not_to include('Some additional information') + end + + it 'does not render the pending A level if the question is not answered' do + a_level_subject_requirement = { 'subject' => 'other_subject', 'other_subject' => 'Math', 'minimum_grade_required' => 'A' } + course = create(:course, accept_pending_a_level: nil, a_level_requirements: true, a_level_subject_requirements: [a_level_subject_requirement]) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).not_to include('Candidates with pending A levels will') + end + + it 'does not render the equivalency A level if the question is not answered' do + a_level_subject_requirement = { 'subject' => 'other_subject', 'other_subject' => 'Math', 'minimum_grade_required' => 'A' } + course = create(:course, accept_a_level_equivalency: nil, a_level_requirements: true, a_level_subject_requirements: [a_level_subject_requirement]) + component = described_class.new(course: course.decorate) + rendered_component = render_inline(component) + + expect(rendered_component.text).not_to include('Equivalency tests will ') + end + + it 'returns false for has_errors?' do + course = create(:course) + component = described_class.new(course: course.decorate) + + expect(component.has_errors?).to be(false) + end +end diff --git a/spec/features/publish/courses/editing_a_levels_tda_course_spec.rb b/spec/features/publish/courses/editing_a_levels_tda_course_spec.rb index 7a4cce6a76..9ce99111ba 100644 --- a/spec/features/publish/courses/editing_a_levels_tda_course_spec.rb +++ b/spec/features/publish/courses/editing_a_levels_tda_course_spec.rb @@ -122,6 +122,10 @@ when_i_enter_on_a_level_equivalencies then_the_yes_option_is_chosen_in_a_level_equivalencies and_i_see_the_additional_a_level_equivalencies_text + + when_i_click_update_a_levels + then_i_am_on_the_course_description_tab + and_i_see_the_a_level_requirements_for_the_course end def given_i_am_authenticated_as_a_provider_user @@ -356,9 +360,10 @@ def then_i_am_on_a_level_equivalencies_page ) end - def and_i_click_update_a_levels + def when_i_click_update_a_levels click_on 'Update A levels' end + alias_method :and_i_click_update_a_levels, :when_i_click_update_a_levels def then_i_see_an_error_message_for_the_a_level_equivalencies expect(page).to have_content('Select if you will consider candidates who need to take equivalency tests').twice @@ -400,4 +405,14 @@ def then_the_yes_option_is_chosen_in_a_level_equivalencies def and_i_see_the_additional_a_level_equivalencies_text expect(page.find('textarea').value).to eq('Some additional A level equivalencies text') end + + def and_i_see_the_a_level_requirements_for_the_course + expect(page).to have_content('Any subject - Grade C or above, or equivalent') + expect(page).to have_content('Any STEM subject - Grade C or above, or equivalent') + expect(page).to have_content('Any humanities subject, or equivalent') + expect(page).to have_content('Mathematics, or equivalent') + expect(page).to have_content('Candidates with pending A levels will not be considered.') + expect(page).to have_content('Equivalency tests will be considered.') + expect(page).to have_content('Some additional A level equivalencies text') + end end