From e680389e8c04ed175f49883814eafbd2153c6381 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 4 Oct 2023 18:33:27 +0100 Subject: [PATCH 1/2] Add review recommendation This adds a new assessment recommendation called review which is used when we need to send an application to review after verification. --- app/models/assessment.rb | 57 +++++---- config/locales/helpers.en.yml | 3 +- spec/models/assessment_spec.rb | 227 ++++++++++++++++++--------------- 3 files changed, 161 insertions(+), 126 deletions(-) diff --git a/app/models/assessment.rb b/app/models/assessment.rb index 91853284c3..3c6925187f 100644 --- a/app/models/assessment.rb +++ b/app/models/assessment.rb @@ -43,12 +43,12 @@ class Assessment < ApplicationRecord enum :recommendation, { award: "award", - verify: "verify", decline: "decline", request_further_information: "request_further_information", + review: "review", unknown: "unknown", - }, - default: :unknown + verify: "verify", + } validates :recommendation, presence: true, @@ -56,18 +56,10 @@ class Assessment < ApplicationRecord in: recommendations.values, } - def unknown! - update!(recommendation: "unknown", recommended_at: nil) - end - def award! update!(recommendation: "award", recommended_at: Time.zone.now) end - def verify! - update!(recommendation: "verify", recommended_at: Time.zone.now) - end - def decline! update!(recommendation: "decline", recommended_at: Time.zone.now) end @@ -79,6 +71,18 @@ def request_further_information! ) end + def review! + update!(recommendation: "review", recommended_at: Time.zone.now) + end + + def unknown! + update!(recommendation: "unknown", recommended_at: nil) + end + + def verify! + update!(recommendation: "verify", recommended_at: Time.zone.now) + end + def completed? award? || decline? end @@ -99,14 +103,6 @@ def can_award? end end - def can_verify? - return false unless application_form.created_under_new_regulations? - - return false if skip_verification? - - all_sections_or_further_information_requests_passed? - end - def can_decline? if unknown? any_preliminary_section_failed? || @@ -130,19 +126,36 @@ def can_request_further_information? end end + def can_review? + return false unless application_form.created_under_new_regulations? + + return false if skip_verification? + + false + end + + def can_verify? + return false unless application_form.created_under_new_regulations? + + return false if skip_verification? + + all_sections_or_further_information_requests_passed? + end + def recommendable? - can_award? || can_verify? || can_decline? || - can_request_further_information? + can_award? || can_decline? || can_request_further_information? || + can_review? || can_verify? end def available_recommendations [].tap do |recommendations| recommendations << "award" if can_award? - recommendations << "verify" if can_verify? recommendations << "decline" if can_decline? if can_request_further_information? recommendations << "request_further_information" end + recommendations << "review" if can_review? + recommendations << "verify" if can_verify? end end diff --git a/config/locales/helpers.en.yml b/config/locales/helpers.en.yml index fc6cf3f8a6..d018a569c9 100644 --- a/config/locales/helpers.en.yml +++ b/config/locales/helpers.en.yml @@ -65,9 +65,10 @@ en: assessor_interface_assessment_recommendation_form: recommendation_options: award: Award QTS - verify: Award QTS decline: Decline QTS request_further_information: Request further information + review: Send application for review + verify: Award QTS assessor_interface_assessment_confirmation_form: confirmation_options: true: "Yes" diff --git a/spec/models/assessment_spec.rb b/spec/models/assessment_spec.rb index ffa38c9b01..4f27d29499 100644 --- a/spec/models/assessment_spec.rb +++ b/spec/models/assessment_spec.rb @@ -52,11 +52,12 @@ it do is_expected.to define_enum_for(:recommendation).with_values( - unknown: "unknown", award: "award", - verify: "verify", decline: "decline", request_further_information: "request_further_information", + review: "review", + unknown: "unknown", + verify: "verify", ).backed_by_column_of_type(:string) end end @@ -192,107 +193,6 @@ end end - describe "#can_verify?" do - subject(:can_verify?) { assessment.can_verify? } - - context "with an application under new regulations" do - let(:application_form) { create(:application_form) } - - context "with an unknown assessment" do - before do - create(:assessment_section, :personal_information, assessment:) - end - it { is_expected.to be false } - end - - context "with a passed assessment" do - before do - create( - :assessment_section, - :personal_information, - :passed, - assessment:, - ) - end - it { is_expected.to be true } - end - - context "with a passed assessment and reduced evidence" do - before do - application_form.update!(reduced_evidence_accepted: true) - create( - :assessment_section, - :personal_information, - :passed, - assessment:, - ) - end - it { is_expected.to be false } - end - - context "with a passed assessment and work history not required" do - before do - application_form.update!(needs_work_history: false) - create( - :assessment_section, - :personal_information, - :passed, - assessment:, - ) - end - it { is_expected.to be false } - end - - context "with a failed assessment" do - before do - create( - :assessment_section, - :personal_information, - :failed, - assessment:, - ) - end - it { is_expected.to be false } - - context "when further information was requested" do - before { assessment.request_further_information! } - - context "with a passed further information request" do - before do - create(:further_information_request, :passed, assessment:) - end - it { is_expected.to be true } - end - - context "with a failed further information request" do - before do - create(:further_information_request, :failed, assessment:) - end - it { is_expected.to be false } - end - end - end - - context "with a mixture of assessments" do - before do - create( - :assessment_section, - :personal_information, - :passed, - assessment:, - ) - create(:assessment_section, :qualifications, :failed, assessment:) - end - it { is_expected.to be false } - end - end - - context "with an application under old regulations" do - let(:application_form) { create(:application_form, :old_regs) } - it { is_expected.to be false } - end - end - describe "#can_decline?" do subject(:can_decline?) { assessment.can_decline? } @@ -430,6 +330,127 @@ end end + describe "#can_review?" do + subject(:can_review?) { assessment.can_review? } + + context "with an application under new regulations" do + let(:application_form) { create(:application_form) } + + context "with an unknown assessment" do + before do + create(:assessment_section, :personal_information, assessment:) + end + it { is_expected.to be false } + end + end + + context "with an application under old regulations" do + let(:application_form) { create(:application_form, :old_regs) } + it { is_expected.to be false } + end + end + + describe "#can_verify?" do + subject(:can_verify?) { assessment.can_verify? } + + context "with an application under new regulations" do + let(:application_form) { create(:application_form) } + + context "with an unknown assessment" do + before do + create(:assessment_section, :personal_information, assessment:) + end + it { is_expected.to be false } + end + + context "with a passed assessment" do + before do + create( + :assessment_section, + :personal_information, + :passed, + assessment:, + ) + end + it { is_expected.to be true } + end + + context "with a passed assessment and reduced evidence" do + before do + application_form.update!(reduced_evidence_accepted: true) + create( + :assessment_section, + :personal_information, + :passed, + assessment:, + ) + end + it { is_expected.to be false } + end + + context "with a passed assessment and work history not required" do + before do + application_form.update!(needs_work_history: false) + create( + :assessment_section, + :personal_information, + :passed, + assessment:, + ) + end + it { is_expected.to be false } + end + + context "with a failed assessment" do + before do + create( + :assessment_section, + :personal_information, + :failed, + assessment:, + ) + end + it { is_expected.to be false } + + context "when further information was requested" do + before { assessment.request_further_information! } + + context "with a passed further information request" do + before do + create(:further_information_request, :passed, assessment:) + end + it { is_expected.to be true } + end + + context "with a failed further information request" do + before do + create(:further_information_request, :failed, assessment:) + end + it { is_expected.to be false } + end + end + end + + context "with a mixture of assessments" do + before do + create( + :assessment_section, + :personal_information, + :passed, + assessment:, + ) + create(:assessment_section, :qualifications, :failed, assessment:) + end + it { is_expected.to be false } + end + end + + context "with an application under old regulations" do + let(:application_form) { create(:application_form, :old_regs) } + it { is_expected.to be false } + end + end + describe "#available_recommendations" do subject(:available_recommendations) { assessment.available_recommendations } From 86f3ff83b3325e9bb23189741a47539368b09c1c Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 5 Oct 2023 12:16:45 +0100 Subject: [PATCH 2/2] Add review task list items This adds a new task list item for assessors for accessing any verifications that need reviewing. --- .../application_forms_show_view_object.rb | 115 ++++++++++++++---- config/locales/assessor_interface.en.yml | 5 +- ...application_forms_show_view_object_spec.rb | 47 ++++++- 3 files changed, 140 insertions(+), 27 deletions(-) diff --git a/app/view_objects/assessor_interface/application_forms_show_view_object.rb b/app/view_objects/assessor_interface/application_forms_show_view_object.rb index 8f5e2db1cc..c5ea3abc6a 100644 --- a/app/view_objects/assessor_interface/application_forms_show_view_object.rb +++ b/app/view_objects/assessor_interface/application_forms_show_view_object.rb @@ -23,6 +23,7 @@ def task_list_sections pre_assessment_task_list_section, assessment_task_list_section, verification_task_list_section, + review_task_list_section, ].compact end @@ -83,7 +84,10 @@ def management_tasks :teaching_authority_provides_written_statement, :work_histories, to: :application_form - delegate :professional_standing_request, to: :assessment + delegate :professional_standing_request, + :qualification_requests, + :reference_requests, + to: :assessment delegate :canonical_email, to: :teacher def pre_assessment_task_list_section @@ -254,7 +258,7 @@ def verification_task_list_section review_professional_standing_request_task_list_item, ].compact - items << assessment_recommendation_task_list_item if items.present? + items << verification_decision_task_list_item if items.present? { title: @@ -312,27 +316,6 @@ def reference_requests_task_list_item } end - def assessment_recommendation_task_list_item - { - name: - I18n.t( - "assessor_interface.application_forms.show.assessment_tasks.items.assessment_recommendation", - ), - link: - if assessment.recommendable? - [:edit, :assessor_interface, application_form, assessment] - end, - status: - if assessment.completed? - :completed - elsif !assessment.recommendable? - :cannot_start - else - :not_started - end, - } - end - def locate_professional_standing_request_task_list_item if teaching_authority_provides_written_statement || professional_standing_request.blank? @@ -397,6 +380,92 @@ def review_professional_standing_request_task_list_item } end + def verification_decision_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.verification_decision", + ), + link: + if assessment.verify? && assessment.recommendable? + [:edit, :assessor_interface, application_form, assessment] + end, + status: + if assessment.review? || assessment.completed? + :completed + elsif !assessment.recommendable? + :cannot_start + else + :not_started + end, + } + end + + def review_task_list_section + return unless pre_assessment_complete? + return if assessment.verify? + + if ( + !teaching_authority_provides_written_statement && + professional_standing_request&.verify_failed? + ) || qualification_requests.any?(&:verify_failed?) || + reference_requests.any?(&:verify_failed?) + { + title: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.sections.review", + ), + items: [ + review_verifications_task_list_item, + review_decision_task_list_item, + ], + } + end + end + + def review_verifications_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.review_verifications", + ), + link: [:edit, :assessor_interface, application_form, assessment], + status: + if assessment.recommendable? + :completed + elsif ( + !teaching_authority_provides_written_statement && + professional_standing_request&.reviewed? + ) || qualification_requests.any?(&:reviewed?) || + reference_requests.any?(&:reviewed?) + :in_progress + else + :not_started + end, + } + end + + def review_decision_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.assessment_decision", + ), + link: + if assessment.recommendable? + [:edit, :assessor_interface, application_form, assessment] + end, + status: + if assessment.completed? + :completed + elsif !assessment.recommendable? + :cannot_start + else + :not_started + end, + } + end + def pre_assessment_complete? return false unless assessment.all_preliminary_sections_passed? diff --git a/config/locales/assessor_interface.en.yml b/config/locales/assessor_interface.en.yml index 729d4ead17..a44c957bb2 100644 --- a/config/locales/assessor_interface.en.yml +++ b/config/locales/assessor_interface.en.yml @@ -16,9 +16,10 @@ en: sections: assessment: Assessment pre_assessment_tasks: Pre-assessment tasks + review: Review verification: Verification items: - assessment_recommendation: Assessment recommendation + assessment_decision: Assessment decision await_professional_standing_request: Awaiting third-party professional standing initial_assessment_recommendation: Initial assessment recommendation locate_professional_standing_request: Record LOPS response @@ -26,6 +27,8 @@ en: reference_requests: Verify reference requests review_professional_standing_request: Review LOPS response review_requested_information: Review requested information from applicant + review_verifications: Review verifications + verification_decision: Verification decision assessments: edit: diff --git a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb index 0f78a1cea4..ae9a464c01 100644 --- a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb @@ -376,7 +376,7 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end @@ -393,7 +393,7 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end @@ -410,10 +410,51 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end + + context "with a failed verified professional standing request" do + before do + create( + :professional_standing_request, + assessment:, + verify_passed: false, + ) + end + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end + + context "with a failed verified qualification request" do + before do + create(:qualification_request, assessment:, verify_passed: false) + end + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end + + context "with a failed verified reference request" do + before { create(:reference_request, assessment:, verify_passed: false) } + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end end describe "#email_used_as_reference_in_this_application_form?" do