diff --git a/app/controllers/assessor_interface/assessment_sections_controller.rb b/app/controllers/assessor_interface/assessment_sections_controller.rb index 51887845d9..6302cb9d1e 100644 --- a/app/controllers/assessor_interface/assessment_sections_controller.rb +++ b/app/controllers/assessor_interface/assessment_sections_controller.rb @@ -15,7 +15,7 @@ def show end def update - unless view_object.show_form? + if view_object.disable_form? redirect_to [ :assessor_interface, application_form, diff --git a/app/view_objects/assessor_interface/assessment_section_view_object.rb b/app/view_objects/assessor_interface/assessment_section_view_object.rb index d218ec50ef..5d13c0768e 100644 --- a/app/view_objects/assessor_interface/assessment_section_view_object.rb +++ b/app/view_objects/assessor_interface/assessment_section_view_object.rb @@ -61,6 +61,13 @@ def show_form? true end + def disable_form? + return true unless show_form? + return true unless assessment.unknown? + + preliminary? ? assessment.all_preliminary_sections_passed? : false + end + def show_english_language_exemption_content? assessment_section.english_language_proficiency? && application_form.english_language_exempt? diff --git a/app/views/assessor_interface/assessment_sections/_form.html.erb b/app/views/assessor_interface/assessment_sections/_form.html.erb index c9c770e5f0..767e06bea7 100644 --- a/app/views/assessor_interface/assessment_sections/_form.html.erb +++ b/app/views/assessor_interface/assessment_sections/_form.html.erb @@ -11,7 +11,8 @@ label: { text: t(view_object.assessment_section.key, scope: %i[assessor_interface assessment_sections english_language_proficiency passed]), size: "s", - } %> + }, + disabled: view_object.disable_form? %> <% end %> <% if view_object.show_english_language_provider_details? %> @@ -34,13 +35,16 @@ <% end %> <% if form.is_a?(AssessorInterface::ScotlandFullRegistrationForm) %> - <%= f.govuk_collection_radio_buttons :scotland_full_registration, %i[true false], :itself %> + <%= f.govuk_radio_buttons_fieldset :scotland_full_registration do %> + <%= f.govuk_radio_button :scotland_full_registration, :true, link_errors: true, disabled: view_object.disable_form? %> + <%= f.govuk_radio_button :scotland_full_registration, :false, disabled: view_object.disable_form? %> + <% end %> <% end %> <% if form.is_a?(AssessorInterface::InductionRequiredForm) %> <%= f.govuk_radio_buttons_fieldset :induction_required, legend: { text: t(view_object.country.code, scope: %i[assessor_interface assessment_sections induction_required]) } do %> - <%= f.govuk_radio_button :induction_required, :false, link_errors: true %> - <%= f.govuk_radio_button :induction_required, :true do %> + <%= f.govuk_radio_button :induction_required, :false, link_errors: true, disabled: view_object.disable_form? %> + <%= f.govuk_radio_button :induction_required, :true, disabled: view_object.disable_form? do %>
We can still award QTS, but applicant must complete a statutory induction period.
<% end %> <% end %> @@ -48,7 +52,7 @@ <% if view_object.preliminary? %> <% view_object.failure_reasons.each do |failure_reason| %> - <%= f.govuk_collection_radio_buttons "#{failure_reason}_checked".to_sym, + <%= f.govuk_collection_radio_buttons :"#{failure_reason}_checked", [ OpenStruct.new(value: :false, label: "Yes"), OpenStruct.new(value: :true, label: "No") @@ -56,22 +60,28 @@ :value, :label, legend: { text: t(failure_reason, scope: %i[assessor_interface assessment_sections failure_reasons as_question label]), size: "s" }, - hint: { text: t(failure_reason, scope: %i[assessor_interface assessment_sections failure_reasons as_question hint], default: "") }%> + hint: { text: t(failure_reason, scope: %i[assessor_interface assessment_sections failure_reasons as_question hint], default: "") }, + disabled: view_object.disable_form? %> <% end %> <% else %> <%= f.govuk_radio_buttons_fieldset :passed, legend: { text: "Has the applicant completed this section to your satisfaction?" } do %> - <%= f.govuk_radio_button :passed, true, label: { text: "Yes" }, link_errors: true %> - <%= f.govuk_radio_button :passed, false, label: { text: "No" } do %> + <%= f.govuk_radio_button :passed, true, label: { text: "Yes" }, link_errors: true, disabled: view_object.disable_form? %> + <%= f.govuk_radio_button :passed, false, label: { text: "No" }, disabled: view_object.disable_form? do %> <%= f.govuk_check_boxes_fieldset :selected_failure_reasons, legend: { size: "s" } do %> <% view_object.failure_reasons.each do |failure_reason| %> - <%= f.govuk_check_box "#{failure_reason}_checked".to_sym, true, label: { text: t(failure_reason, scope: %i[assessor_interface assessment_sections failure_reasons as_statement]) } do %> - <%= f.govuk_text_area "#{failure_reason}_notes".to_sym, + <%= f.govuk_check_box :"#{failure_reason}_checked", true, label: { text: t(failure_reason, scope: %i[assessor_interface assessment_sections failure_reasons as_statement]) }, disabled: view_object.disable_form? do %> + <%= f.govuk_text_area :"#{failure_reason}_notes", label: { text: t(view_object.notes_label_key_for(failure_reason:)), size: "s" }, hint: { text: t(view_object.notes_hint_key_for(failure_reason:)) }, - placeholder: t(view_object.notes_placeholder_key_for(failure_reason:)) %> + placeholder: t(view_object.notes_placeholder_key_for(failure_reason:)), + disabled: view_object.disable_form? %> <% if FailureReasons::chooses_work_history?(failure_reason) %> - <%= f.govuk_collection_check_boxes :"#{failure_reason}_work_history_checked", view_object.work_histories, :id, :school_name, multiple: false, legend: { size: "s" } %> + <%= f.govuk_check_boxes_fieldset :"#{failure_reason}_work_history_checked", legend: { size: "s" } do %> + <% view_object.work_histories.each do |work_history| %> + <%= f.govuk_check_box :"#{failure_reason}_work_history_checked", work_history.id, label: { text: work_history.school_name }, disabled: view_object.disable_form? %> + <% end %> + <% end %> <% end %> <% end %> <% end %> @@ -80,5 +90,7 @@ <% end %> <% end %> - <%= render "shared/assessor_interface/continue_cancel_button", f: %> + <%= f.govuk_submit disabled: !form.is_a?(AssessorInterface::CheckAgeRangeSubjectsForm) && view_object.disable_form? do %> + <%= render "shared/assessor_interface/cancel_link" %> + <% end %> <% end %> diff --git a/app/views/shared/_age_range_subjects_form_fields.html.erb b/app/views/shared/_age_range_subjects_form_fields.html.erb index eee9620219..a92d81198f 100644 --- a/app/views/shared/_age_range_subjects_form_fields.html.erb +++ b/app/views/shared/_age_range_subjects_form_fields.html.erb @@ -1,4 +1,4 @@ -<%= f.govuk_fieldset legend: { text: 'What age range is the applicant qualified to teach?' } do %> +<%= f.govuk_fieldset legend: { text: "What age range is the applicant qualified to teach?" } do %>Based on the evidence the applicant has provided, you can either copy the age range they entered if you agree, or enter a new range.
<%= f.govuk_number_field :age_range_min, width: 3 %> @@ -19,7 +19,7 @@ options_for_select( dfe_autocomplete_options(Subject.all), f.object.send(field), - ), + ) ) ) %> <% end %> diff --git a/spec/forms/assessor_interface/assessment_section_form_spec.rb b/spec/forms/assessor_interface/assessment_section_form_spec.rb index 4f6278af6c..e88cb55171 100644 --- a/spec/forms/assessor_interface/assessment_section_form_spec.rb +++ b/spec/forms/assessor_interface/assessment_section_form_spec.rb @@ -68,7 +68,7 @@ end it do is_expected.not_to validate_presence_of( - "#{decline_failure_reason}_notes".to_sym, + :"#{decline_failure_reason}_notes", ) end end @@ -76,14 +76,14 @@ context "when reasons are checked and notes are provided" do let(:attributes) do { - :passed => false, - :"#{further_information_failure_reason}_checked" => true, - :"#{further_information_failure_reason}_notes" => "Notes.", - :"#{work_history_failure_reason}_checked" => true, - :"#{work_history_failure_reason}_notes" => "Notes.", - :"#{work_history_failure_reason}_work_history_checked" => [1], - "#{decline_failure_reason}_checked".to_sym => true, - "#{decline_failure_reason}_notes".to_sym => "Notes", + passed: false, + "#{further_information_failure_reason}_checked": true, + "#{further_information_failure_reason}_notes": "Notes.", + "#{work_history_failure_reason}_checked": true, + "#{work_history_failure_reason}_notes": "Notes.", + "#{work_history_failure_reason}_work_history_checked": [1], + "#{decline_failure_reason}_checked": true, + "#{decline_failure_reason}_notes": "Notes", } end