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 12, 2024
1 parent 06be245 commit b0e555e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 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: 26 additions & 12 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 @@ -30,17 +31,20 @@
<% end %>

<% if form.is_a?(AssessorInterface::CheckAgeRangeSubjectsForm) %>
<%= render "shared/age_range_subjects_form_fields", f: %>
<%= render "shared/age_range_subjects_form_fields", f:, disabled: view_object.disable_form? %>
<% 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 %>
Expand All @@ -56,22 +60,30 @@
: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_check_box "#{failure_reason}_checked".to_sym, 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".to_sym,
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_collection_check_boxes :"#{failure_reason}_work_history_checked",
view_object.work_histories,
:id,
:school_name,
multiple: false,
legend: { size: "s" },
disabled: view_object.disable_form? %>
<% end %>
<% end %>
<% end %>
Expand All @@ -80,5 +92,7 @@
<% end %>
<% end %>

<%= render "shared/assessor_interface/continue_cancel_button", f: %>
<%= f.govuk_submit disabled: view_object.disable_form? do %>
<%= render "shared/assessor_interface/cancel_link" %>
<% end %>
<% end %>
14 changes: 9 additions & 5 deletions app/views/shared/_age_range_subjects_form_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<% disabled ||= false %>

<%= 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 %>
<%= f.govuk_number_field :age_range_max, width: 3 %>
<%= f.govuk_text_area :age_range_note, label: { text: t("helpers.label.assessor_interface_assessment_section_form.age_range_note").html_safe } %>
<%= f.govuk_number_field :age_range_min, width: 3, disabled: %>
<%= f.govuk_number_field :age_range_max, width: 3, disabled: %>
<%= f.govuk_text_area :age_range_note, label: { text: t("helpers.label.assessor_interface_assessment_section_form.age_range_note").html_safe }, disabled: %>
<% end %>

<h2 class="govuk-heading-m">Which subjects can the applicant teach in England?</h2>
Expand All @@ -20,8 +22,10 @@
dfe_autocomplete_options(Subject.all),
f.object.send(field),
),
)
disabled:
),
html_attributes: { disabled: disabled ? "disabled" : "" }
) %>
<% end %>

<%= f.govuk_text_area :subjects_note, label: { text: t("helpers.label.assessor_interface_assessment_section_form.subjects_note").html_safe } %>
<%= f.govuk_text_area :subjects_note, label: { text: t("helpers.label.assessor_interface_assessment_section_form.subjects_note").html_safe }, disabled: %>

0 comments on commit b0e555e

Please sign in to comment.