Skip to content

Commit

Permalink
Disable assessment forms after assessment
Browse files Browse the repository at this point in the history
When a recommendation has been made by an assessor we should disable the
forms to prevent them being modified after an assessment has been made.
  • Loading branch information
thomasleese committed Apr 23, 2024
1 parent f8bc175 commit 29085a8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
38 changes: 25 additions & 13 deletions app/views/assessor_interface/assessment_sections/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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? %>
Expand All @@ -34,44 +35,53 @@
<% 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 %>
<p class="govuk-hint">We can still award QTS, but applicant must complete a statutory induction period.</p>
<% end %>
<% end %>
<% end %>

<% 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")
],
: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 %>
<div id="assessor-interface-assessment-section-form-selected-failure-reasons-field-error"></div>
<%= 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 %>
Expand All @@ -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 %>
4 changes: 2 additions & 2 deletions app/views/shared/_age_range_subjects_form_fields.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
<p class="govuk-body">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.</p>

<%= f.govuk_number_field :age_range_min, width: 3 %>
Expand All @@ -19,7 +19,7 @@
options_for_select(
dfe_autocomplete_options(Subject.all),
f.object.send(field),
),
)
)
) %>
<% end %>
Expand Down
18 changes: 9 additions & 9 deletions spec/forms/assessor_interface/assessment_section_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@
end
it do
is_expected.not_to validate_presence_of(
"#{decline_failure_reason}_notes".to_sym,
:"#{decline_failure_reason}_notes",
)
end
end

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

Expand Down

0 comments on commit 29085a8

Please sign in to comment.