diff --git a/app/controllers/concerns/jobseekers/qualification_form_concerns.rb b/app/controllers/concerns/jobseekers/qualification_form_concerns.rb index 3eeace9ede..c79315b40a 100644 --- a/app/controllers/concerns/jobseekers/qualification_form_concerns.rb +++ b/app/controllers/concerns/jobseekers/qualification_form_concerns.rb @@ -6,21 +6,15 @@ def qualification_form_param_key(category) end def category_form_class(category) - name = if %w[select_category submit_category].include?(action_name) - "CategoryForm" - elsif %w[confirm_destroy].include?(action_name) - "DeleteForm" - else - case category - when "gcse", "a_level", "as_level" - "Secondary::CommonForm" - when "other_secondary" - "Secondary::OtherForm" - when "undergraduate", "postgraduate" - "DegreeForm" - when "other" - "OtherForm" - end + name = case category + when "gcse", "a_level", "as_level" + "Secondary::CommonForm" + when "other_secondary" + "Secondary::OtherForm" + when "undergraduate", "postgraduate" + "DegreeForm" + when "other" + "OtherForm" end "Jobseekers::Qualifications::#{name}".constantize end diff --git a/app/controllers/jobseekers/job_applications/qualifications_controller.rb b/app/controllers/jobseekers/job_applications/qualifications_controller.rb index 4752f69906..e648dbaba4 100644 --- a/app/controllers/jobseekers/job_applications/qualifications_controller.rb +++ b/app/controllers/jobseekers/job_applications/qualifications_controller.rb @@ -1,72 +1,78 @@ class Jobseekers::JobApplications::QualificationsController < Jobseekers::BaseController include Jobseekers::QualificationFormConcerns - helper_method :back_path, :category, :form, :job_application, :qualification, :secondary?, :qualification_form_param_key + helper_method :back_path, :job_application, :qualification_form_param_key + + before_action :set_qualification, only: %i[edit update destroy] + + def select_category + @form = Jobseekers::Qualifications::CategoryForm.new + end def submit_category - if form.valid? - redirect_to new_jobseekers_job_application_qualification_path(qualification_params) + @category = category_param + @form = Jobseekers::Qualifications::CategoryForm.new(submit_category_params) + + if @form.valid? + redirect_to new_jobseekers_job_application_qualification_path(submit_category_params) else - render :select_category + render :select_category, status: :unprocessable_entity end end + def new + @category = category_param + @form = category_form_class(@category).new(category: @category) + end + + def edit + @category = @qualification.category + edit_attributes = @qualification + .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) + .reject { |_, v| v.blank? && v != false } + + @form = category_form_class(@category).new(edit_attributes) + end + def create - if form.valid? + @category = category_param + @form = category_form_class(@category).new(qualification_params) + + if @form.valid? job_application.qualifications.create(qualification_params) redirect_to back_path else - render :new + render :new, status: :unprocessable_entity end end def update - if form.valid? - qualification.update(qualification_params) + @category = @qualification.category + @form = category_form_class(@category).new(qualification_params) + + if @form.valid? + @qualification.update(qualification_params) redirect_to back_path else - render :edit + render :edit, status: :unprocessable_entity end end def destroy - qualification.destroy + @qualification.destroy redirect_to back_path, success: t(".success") end private - def form - @form ||= category_form_class(category).new(form_attributes) - end - - def form_attributes - case action_name - when "new" - { category: category } - when "select_category" - {} - when "edit" - qualification - .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) - .reject { |_, v| v.blank? && v != false } - when "create", "update", "submit_category" - qualification_params - end + def submit_category_params + key = ActiveModel::Naming.param_key(Jobseekers::Qualifications::CategoryForm) + (params[key] || params).permit(:category) end def qualification_params - case action_name - when "new", "select_category", "submit_category" - (params[qualification_form_param_key(category)] || params).permit(:category) - when "create", "edit", "update" - params.require(qualification_form_param_key(category)) - .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade]) - end - end - - def category - @category ||= action_name.in?(%w[edit update]) ? qualification.category : category_param + params.require(qualification_form_param_key(@category)) + .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade awarding_body]) end def category_param @@ -81,11 +87,7 @@ def job_application @job_application ||= current_jobseeker.job_applications.draft.find(params[:job_application_id]) end - def qualification - @qualification ||= job_application.qualifications.find(params[:id]) - end - - def secondary? - category.in?(Qualification::SECONDARY_QUALIFICATIONS) + def set_qualification + @qualification = job_application.qualifications.find(params[:id]) end end diff --git a/app/controllers/jobseekers/profiles/qualifications_controller.rb b/app/controllers/jobseekers/profiles/qualifications_controller.rb index 5c8b5e7cc4..683cd24831 100644 --- a/app/controllers/jobseekers/profiles/qualifications_controller.rb +++ b/app/controllers/jobseekers/profiles/qualifications_controller.rb @@ -1,24 +1,33 @@ class Jobseekers::Profiles::QualificationsController < Jobseekers::ProfilesController include Jobseekers::QualificationFormConcerns - helper_method :category, :form, :jobseeker_profile, :qualification, :secondary?, :qualification_form_param_key + helper_method :jobseeker_profile, :qualification, :qualification_form_param_key + + before_action :set_form_and_category, only: %i[new create edit update] + + def select_category + @form = Jobseekers::Qualifications::CategoryForm.new + end def submit_category - if form.valid? - redirect_to new_jobseekers_profile_qualification_path(qualification_params) + @category = category_param + @form = Jobseekers::Qualifications::CategoryForm.new(submit_category_params) + + if @form.valid? + redirect_to new_jobseekers_profile_qualification_path(submit_category_params) else - render :select_category + render :select_category, status: :unprocessable_entity end end def new; end def create - if form.valid? + if @form.valid? profile.qualifications.create(qualification_params) redirect_to review_jobseekers_profile_qualifications_path else - render :new + render :new, status: :unprocessable_entity end end @@ -27,11 +36,11 @@ def edit; end def review; end def update - if form.valid? + if @form.valid? qualification.update(qualification_params) redirect_to review_jobseekers_profile_qualifications_path else - render :edit + render :edit, status: :unprocessable_entity end end @@ -40,41 +49,44 @@ def destroy redirect_to review_jobseekers_profile_qualifications_path, success: t(".success") end - def confirm_destroy; end + def confirm_destroy + @category = qualification.category + @form = Jobseekers::Qualifications::DeleteForm.new + end private - def form - @form ||= category_form_class(category).new(form_attributes) - end - def form_attributes case action_name when "new" - { category: category } - when "select_category", "confirm_destroy" - {} + { category: @category } when "edit" qualification .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) .reject { |_, v| v.blank? && v != false } - when "create", "update", "submit_category" + when "create", "update" qualification_params end end + def submit_category_params + key = ActiveModel::Naming.param_key(Jobseekers::Qualifications::CategoryForm) + (params[key] || params).permit(:category) + end + def qualification_params case action_name - when "new", "select_category", "submit_category", "confirm_destroy" - (params[qualification_form_param_key(category)] || params).permit(:category) + when "new", "confirm_destroy" + (params[qualification_form_param_key(@category)] || params).permit(:category) when "create", "edit", "update" - params.require(qualification_form_param_key(category)) - .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade]) + params.require(qualification_form_param_key(@category)) + .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade awarding_body]) end end - def category - @category ||= action_name.in?(%w[edit update confirm_destroy]) ? qualification.category : category_param + def set_form_and_category + @category = action_name.in?(%w[edit update]) ? qualification.category : category_param + @form = category_form_class(@category).new(form_attributes) end def category_param @@ -84,8 +96,4 @@ def category_param def qualification @qualification ||= profile.qualifications.find(params[:id] || params[:qualification_id]) end - - def secondary? - category.in?(Qualification::SECONDARY_QUALIFICATIONS) - end end diff --git a/app/form_models/jobseekers/qualifications/qualification_form.rb b/app/form_models/jobseekers/qualifications/qualification_form.rb index 996060a40e..4efe5eca43 100644 --- a/app/form_models/jobseekers/qualifications/qualification_form.rb +++ b/app/form_models/jobseekers/qualifications/qualification_form.rb @@ -7,4 +7,8 @@ class Jobseekers::Qualifications::QualificationForm validates :finished_studying_details, presence: true, if: -> { finished_studying == "false" } validates :year, numericality: { less_than_or_equal_to: proc { Time.current.year } }, if: -> { finished_studying == "true" } + + def secondary? + false + end end diff --git a/app/form_models/jobseekers/qualifications/secondary/common_form.rb b/app/form_models/jobseekers/qualifications/secondary/common_form.rb index fa45964a4d..1780329661 100644 --- a/app/form_models/jobseekers/qualifications/secondary/common_form.rb +++ b/app/form_models/jobseekers/qualifications/secondary/common_form.rb @@ -14,6 +14,10 @@ def initialize(attributes = nil) pad_qualification_results end + def secondary? + true + end + def qualification_results_attributes=(attrs) @qualification_results = attrs.map { |_, params| QualificationResultForm.new(params) } end diff --git a/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb b/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb index 825c1808b7..b9bd1000a9 100644 --- a/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb +++ b/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb @@ -1,7 +1,7 @@ class Jobseekers::Qualifications::Secondary::QualificationResultForm include ActiveModel::Model - attr_accessor :id, :subject, :grade + attr_accessor :id, :subject, :grade, :awarding_body validates :subject, presence: true validates :grade, presence: true diff --git a/app/helpers/pdf_helper.rb b/app/helpers/pdf_helper.rb index 05a1c9ec21..136343d4a7 100644 --- a/app/helpers/pdf_helper.rb +++ b/app/helpers/pdf_helper.rb @@ -103,13 +103,15 @@ def add_secondary_qualification_details(pdf, qualification) pdf.move_down 5 pdf.text "Secondary Qualification", size: 12, style: :italic - secondary_qualification_data = [ - ["Name:", qualification.name], - ["Grade:", qualification.grade], - ["Date completed:", qualification.year], - ].reject { |row| row[1].blank? } - - render_table(pdf, secondary_qualification_data) + qualification.qualification_results.each do |result| + secondary_qualification_data = [ + ["Subject:", result.subject], + ["Grade:", result.grade], + (["Awarding Body:", result.awarding_body] if result.awarding_body.present?), + ["Date completed:", qualification.year], + ].compact + render_table(pdf, secondary_qualification_data) + end end def add_general_qualification_details(pdf, qualification) diff --git a/app/helpers/qualifications_helper.rb b/app/helpers/qualifications_helper.rb index 8b1eb2f7ba..b2f3dfc9f4 100644 --- a/app/helpers/qualifications_helper.rb +++ b/app/helpers/qualifications_helper.rb @@ -16,4 +16,12 @@ def qualifications_sort_and_group(qualifications) def qualifications_group_category_other?(qualifications) qualifications.all? { |qualification| qualification.category == "other" } end + + def display_secondary_qualification(res) + if res.awarding_body.blank? + "#{res.subject} – #{res.grade}" + else + "#{res.subject} – #{res.grade} (#{res.awarding_body})" + end + end end diff --git a/app/models/qualification_result.rb b/app/models/qualification_result.rb index f5a2922270..fb8a87cbd5 100644 --- a/app/models/qualification_result.rb +++ b/app/models/qualification_result.rb @@ -8,6 +8,7 @@ def duplicate self.class.new( grade:, subject:, + awarding_body:, ) end diff --git a/app/views/jobseekers/job_applications/build/qualifications.html.slim b/app/views/jobseekers/job_applications/build/qualifications.html.slim index 126ba7a6d5..065e4e57fb 100644 --- a/app/views/jobseekers/job_applications/build/qualifications.html.slim +++ b/app/views/jobseekers/job_applications/build/qualifications.html.slim @@ -17,7 +17,7 @@ - if qualification.secondary? - summary_list.with_row do |row| - row.with_key text: t("jobseekers.job_applications.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - qualification.display_attributes.each do |attribute| - summary_list.with_row do |row| diff --git a/app/views/jobseekers/job_applications/qualifications/edit.html.slim b/app/views/jobseekers/job_applications/qualifications/edit.html.slim index fa3502dc1c..c8fc982962 100644 --- a/app/views/jobseekers/job_applications/qualifications/edit.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/edit.html.slim @@ -1,14 +1,14 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") - = form_for form, url: jobseekers_job_application_qualification_path(job_application, qualification), method: :patch do |f| + = form_for @form, url: jobseekers_job_application_qualification_path(job_application, @qualification), method: :patch do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_button_link_to t("buttons.cancel"), jobseekers_job_application_build_path(job_application, :qualifications), class: "govuk-button--secondary govuk-!-margin-left-3" diff --git a/app/views/jobseekers/job_applications/qualifications/new.html.slim b/app/views/jobseekers/job_applications/qualifications/new.html.slim index d5a03cbc57..a1ce47e765 100644 --- a/app/views/jobseekers/job_applications/qualifications/new.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/new.html.slim @@ -1,15 +1,15 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") p = t(".hint") - = form_for form, url: jobseekers_job_application_qualifications_path(job_application, category: category), method: :post do |f| + = form_for @form, url: jobseekers_job_application_qualifications_path(job_application, category: @category), method: :post do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", category: @category, f: f - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_button_link_to t("buttons.cancel"), select_category_jobseekers_job_application_qualifications_path(job_application), class: "govuk-button--secondary govuk-!-margin-left-3" diff --git a/app/views/jobseekers/job_applications/qualifications/select_category.html.slim b/app/views/jobseekers/job_applications/qualifications/select_category.html.slim index cfbc624521..d238491e31 100644 --- a/app/views/jobseekers/job_applications/qualifications/select_category.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/select_category.html.slim @@ -1,11 +1,11 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") h1.govuk-heading-xl = t(".heading") - = form_for form, url: submit_category_jobseekers_job_application_qualifications_path(job_application), method: :post do |f| + = form_for @form, url: submit_category_jobseekers_job_application_qualifications_path(job_application), method: :post do |f| = f.govuk_error_summary = render "shared/category_fieldset", form: f diff --git a/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim b/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim index 65fd38161f..4e27b6d9d8 100644 --- a/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim +++ b/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim @@ -1,5 +1,5 @@ p class="govuk-!-margin-bottom-1" - = qualification.qualification_results.map { |result| "#{result.subject} (#{result.grade.upcase})" }.join(", ") + = qualification.qualification_results.map { |result| display_secondary_qualification(result) }.join(", ") p.govuk-caption-m - if qualification.display_attributes.include?("institution") diff --git a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim index 07e7fed15a..0121612f7d 100644 --- a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim @@ -28,7 +28,7 @@ - row.with_value text: qualification.year - summary_list.with_row do |row| - row.with_key text: t("jobseekers.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - else - summary_list.with_row do |row| - row.with_key text: "Type" diff --git a/app/views/jobseekers/profiles/qualifications/edit.html.slim b/app/views/jobseekers/profiles/qualifications/edit.html.slim index b2eb4f367c..a7a3ecbfc5 100644 --- a/app/views/jobseekers/profiles/qualifications/edit.html.slim +++ b/app/views/jobseekers/profiles/qualifications/edit.html.slim @@ -6,12 +6,12 @@ .govuk-grid-row .govuk-grid-column-two-thirds - = form_for form, url: jobseekers_profile_qualification_path(params[:id]), method: :patch do |f| + = form_for @form, url: jobseekers_profile_qualification_path(params[:id]), method: :patch do |f| = f.govuk_error_summary = f.govuk_fieldset legend: { text: t(".page_title"), tag: "h1", size: "l" } do - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category = f.govuk_submit t("buttons.save_and_continue") diff --git a/app/views/jobseekers/profiles/qualifications/new.html.slim b/app/views/jobseekers/profiles/qualifications/new.html.slim index a77db4b2cc..61e611f356 100644 --- a/app/views/jobseekers/profiles/qualifications/new.html.slim +++ b/app/views/jobseekers/profiles/qualifications/new.html.slim @@ -1,16 +1,16 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") p = t(".hint") - = form_for form, url: jobseekers_profile_qualifications_path(profile, category: category), method: :post do |f| + = form_for @form, url: jobseekers_profile_qualifications_path(profile, category: @category), method: :post do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_link_to t("buttons.cancel"), jobseekers_profile_path diff --git a/app/views/jobseekers/profiles/qualifications/select_category.html.slim b/app/views/jobseekers/profiles/qualifications/select_category.html.slim index 6b6fb615ae..8bb62ac9da 100644 --- a/app/views/jobseekers/profiles/qualifications/select_category.html.slim +++ b/app/views/jobseekers/profiles/qualifications/select_category.html.slim @@ -1,4 +1,4 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".page_title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".page_title")) - content_for :breadcrumbs do nav.govuk-breadcrumbs aria-label="Breadcrumbs" @@ -8,7 +8,7 @@ .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - = form_for form, url: submit_category_jobseekers_profile_qualifications_path, method: :post do |f| + = form_for @form, url: submit_category_jobseekers_profile_qualifications_path, method: :post do |f| = f.govuk_error_summary = render "shared/category_fieldset", form: f diff --git a/app/views/jobseekers/qualifications/_fields.html.slim b/app/views/jobseekers/qualifications/_fields.html.slim index 711be35513..6a613f90a1 100644 --- a/app/views/jobseekers/qualifications/_fields.html.slim +++ b/app/views/jobseekers/qualifications/_fields.html.slim @@ -2,7 +2,7 @@ - case category - when "gcse", "as_level", "a_level", "other_secondary" - = render "jobseekers/qualifications/fields/secondary_school", f: f + = render "jobseekers/qualifications/fields/secondary_school", f: f, category: category - when "undergraduate", "postgraduate", "degree" = render "jobseekers/qualifications/fields/degree", f: f - when "other" diff --git a/app/views/jobseekers/qualifications/_qualifications.html.slim b/app/views/jobseekers/qualifications/_qualifications.html.slim index f17b4dd0ee..c863bbd8f6 100644 --- a/app/views/jobseekers/qualifications/_qualifications.html.slim +++ b/app/views/jobseekers/qualifications/_qualifications.html.slim @@ -6,7 +6,7 @@ - if qualification.secondary? - summary_list.with_row do |row| - row.with_key text: t("jobseekers.profiles.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - qualification.display_attributes.each do |attribute| - summary_list.with_row do |row| diff --git a/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim b/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim index 4993905ab5..71bd88266f 100644 --- a/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim +++ b/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim @@ -3,12 +3,15 @@ - if category == "other_secondary" = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true }, width: "two-thirds" += f.govuk_number_field :year, label: { size: "s" }, aria: { required: true }, width: 4 + = f.govuk_fieldset legend: { text: t("helpers.legend.jobseekers_qualifications_shared_legends.subjects") }, class: "subjects-and-grades", data: { controller: "manage-qualifications" } do - - form.qualification_results.each_with_index do |result, idx| + - f.object.qualification_results.each_with_index do |result, idx| = f.fields_for :qualification_results, result do |result_form| - .inline-fields-container.subject-row class="#{idx > form.highest_present_result_index ? "js-hidden" : ""}" data-manage-qualifications-target="row" + .inline-fields-container.subject-row class="#{idx > f.object.highest_present_result_index ? "js-hidden" : ""}" data-manage-qualifications-target="row" = result_form.govuk_text_field :subject, label: { text: "Subject #{idx + 1}" }, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-two-thirds" } - = result_form.govuk_text_field :grade, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Subject #{idx + 1} Grade" } + = result_form.govuk_text_field :grade, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Grade" } + = result_form.govuk_text_field :awarding_body, aria: { required: false }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Awarding Body (optional)" } .govuk-form-group.button_to button.govuk-button.js-action.govuk-button--secondary class="govuk-!-margin-bottom-0" data-action="manage-qualifications#deleteRow" type="button" = "#{t('buttons.delete_subject')} #{idx + 1}" @@ -16,5 +19,3 @@ span class="govuk-!-margin-bottom-6 govuk-!-margin-top-0 js-action button_to" button.govuk-button.govuk-button--secondary id="add_subject" data-action="manage-qualifications#addRow" type="button" = t("buttons.add_another_subject") - -= f.govuk_number_field :year, label: { size: "s" }, aria: { required: true }, width: 4 diff --git a/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim b/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim index 65fd38161f..4e27b6d9d8 100644 --- a/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim +++ b/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim @@ -1,5 +1,5 @@ p class="govuk-!-margin-bottom-1" - = qualification.qualification_results.map { |result| "#{result.subject} (#{result.grade.upcase})" }.join(", ") + = qualification.qualification_results.map { |result| display_secondary_qualification(result) }.join(", ") p.govuk-caption-m - if qualification.display_attributes.include?("institution") diff --git a/config/analytics.yml b/config/analytics.yml index 3464b4c639..8a09a37546 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -303,6 +303,7 @@ shared: - qualification_id - subject - grade + - awarding_body - created_at - updated_at references: diff --git a/config/locales/forms.yml b/config/locales/forms.yml index cd2e59a051..e742692d17 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -437,7 +437,7 @@ en: true: "Yes" grade: Grade subject: Subject - year: Year qualification(s) was/were awarded + year: Year awarded jobseekers_job_application_details_reference_form: email: Email address job_title: Job title diff --git a/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb b/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb new file mode 100644 index 0000000000..7b7b5b4f9d --- /dev/null +++ b/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb @@ -0,0 +1,5 @@ +class AddAwardingBodyToQualificationResult < ActiveRecord::Migration[7.2] + def change + add_column :qualification_results, :awarding_body, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index abe02ee18a..83dbe867a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_01_13_131902) do +ActiveRecord::Schema[7.2].define(version: 2025_01_13_144018) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "citext" @@ -514,6 +514,7 @@ t.string "grade", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "awarding_body" t.index ["qualification_id"], name: "index_qualification_results_on_qualification_id" end diff --git a/spec/support/jobseeker_helpers.rb b/spec/support/jobseeker_helpers.rb index 555630b4f0..9c7d26820f 100644 --- a/spec/support/jobseeker_helpers.rb +++ b/spec/support/jobseeker_helpers.rb @@ -109,10 +109,12 @@ def fill_in_reference def fill_in_gcses fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][subject]", with: "Maths" fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][grade]", with: "110%" + fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][awarding_body]", with: "Cambridge Board" + find_by_id("add_subject").click fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][1][subject]", with: "PE" fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][1][grade]", with: "90%" fill_in "School, college, or other organisation", with: "Churchill School for Gifted Macaques" - fill_in "Year qualification(s) was/were awarded", with: "2020" + fill_in I18n.t("helpers.label.jobseekers_qualifications_shared_labels.year"), with: "2020" end def fill_in_custom_secondary_qualifications @@ -122,7 +124,7 @@ def fill_in_custom_secondary_qualifications fill_in "jobseekers_qualifications_secondary_other_form[qualification_results_attributes][1][subject]", with: "German" fill_in "jobseekers_qualifications_secondary_other_form[qualification_results_attributes][1][grade]", with: "4" fill_in "School, college, or other organisation", with: "Happy Rainbows School for High Achievers" - fill_in "Year qualification(s) was/were awarded", with: "2020" + fill_in I18n.t("helpers.label.jobseekers_qualifications_shared_labels.year"), with: "2020" end def fill_in_undergraduate_degree diff --git a/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb index 2ba6301fc3..ecfec05ff2 100644 --- a/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb @@ -55,7 +55,7 @@ expect(current_path).to eq(jobseekers_job_application_build_path(job_application, :qualifications)) expect(page).to have_content("GCSEs") expect(page).to have_content("Churchill School for Gifted Macaques") - expect(page).to have_content("Maths – 110%") + expect(page).to have_content("Maths – 110% (Cambridge Board)") expect(page).to have_content("PE – 90%") expect(page).to have_content("2020") end