diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss
index af652dc58a..099d0a544d 100644
--- a/app/assets/stylesheets/application.sass.scss
+++ b/app/assets/stylesheets/application.sass.scss
@@ -77,3 +77,7 @@ ul.autocomplete__menu {
text-align: right;
vertical-align: middle;
}
+
+.app-background-inset-text {
+ background-color: #f3f2f1;
+}
diff --git a/app/components/status_tag/component.rb b/app/components/status_tag/component.rb
index 086209913f..327025bd04 100644
--- a/app/components/status_tag/component.rb
+++ b/app/components/status_tag/component.rb
@@ -38,20 +38,18 @@ def tags
not_started: "grey",
overdue: "pink",
overdue_consent: "pink",
+ overdue_ecctis: "pink",
overdue_further_information: "pink",
overdue_lops: "pink",
- overdue_professional_standing: "pink",
- overdue_qualification: "pink",
overdue_reference: "pink",
potential_duplicate_in_dqt: "pink",
pre_assessment: "pink",
preliminary_check: "pink",
received: "purple",
received_consent: "purple",
+ received_ecctis: "purple",
received_further_information: "purple",
received_lops: "purple",
- received_professional_standing: "purple",
- received_qualification: "purple",
received_reference: "purple",
rejected: "red",
requested: "yellow",
@@ -63,10 +61,9 @@ def tags
verification_not_started: "grey",
waiting_on: "yellow",
waiting_on_consent: "yellow",
+ waiting_on_ecctis: "yellow",
waiting_on_further_information: "yellow",
waiting_on_lops: "yellow",
- waiting_on_professional_standing: "yellow",
- waiting_on_qualification: "yellow",
waiting_on_reference: "yellow",
withdrawn: "red",
}.freeze
diff --git a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb
index 00c58019d1..14325f0d5b 100644
--- a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb
+++ b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb
@@ -27,6 +27,13 @@ def edit
@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request&.verify_failed?
+ @consent_requests =
+ assessment
+ .consent_requests
+ .includes(:qualification)
+ .where(verify_passed: false)
+ .order_by_role
+
@qualification_requests =
assessment
.qualification_requests
diff --git a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb
index ccf69249d7..752a75c6e4 100644
--- a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb
+++ b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb
@@ -47,6 +47,7 @@ def update
user: current_staff,
professional_standing:,
qualifications:,
+ qualifications_assessor_note: session[:qualifications_assessor_note],
work_histories:,
)
@@ -80,6 +81,9 @@ def update_verify_qualifications
session[:qualification_ids] = []
if @form.verify_qualifications
+ # To ensure the user goes back to the check page afterwards.
+ history_stack.pop if history_stack.last_entry_is_check?
+
redirect_to [
:qualification_requests,
:assessor_interface,
@@ -106,12 +110,7 @@ def update_verify_qualifications
def edit_qualification_requests
authorize %i[assessor_interface assessment_recommendation], :edit?
- @form =
- SelectQualificationsForm.new(
- application_form:,
- session:,
- qualification_ids: application_form.qualifications.pluck(:id),
- )
+ @form = SelectQualificationsForm.new(application_form:, session:)
end
def update_qualification_requests
@@ -123,11 +122,18 @@ def update_qualification_requests
:qualification_ids,
).compact_blank
+ qualifications_assessor_note =
+ params.dig(
+ :assessor_interface_select_qualifications_form,
+ :qualifications_assessor_note,
+ ) || ""
+
@form =
SelectQualificationsForm.new(
application_form:,
- session:,
qualification_ids:,
+ qualifications_assessor_note:,
+ session:,
)
if @form.save
@@ -135,7 +141,7 @@ def update_qualification_requests
redirect_to check_path
else
redirect_to [
- :email_consent_letters,
+ :professional_standing,
:assessor_interface,
application_form,
assessment,
@@ -147,13 +153,6 @@ def update_qualification_requests
end
end
- def email_consent_letters
- authorize %i[assessor_interface assessment_recommendation], :edit?
-
- @qualifications =
- application_form.qualifications.where(id: session[:qualification_ids])
- end
-
def edit_professional_standing
authorize %i[assessor_interface assessment_recommendation], :edit?
diff --git a/app/controllers/assessor_interface/consent_requests_controller.rb b/app/controllers/assessor_interface/consent_requests_controller.rb
index 9a48819c1b..0da446a96e 100644
--- a/app/controllers/assessor_interface/consent_requests_controller.rb
+++ b/app/controllers/assessor_interface/consent_requests_controller.rb
@@ -4,7 +4,181 @@ module AssessorInterface
class ConsentRequestsController < BaseController
include HistoryTrackable
- before_action :set_variables
+ before_action :set_collection_variables,
+ only: %i[new edit_request update_request]
+ before_action :set_member_variables,
+ only: %i[
+ edit_upload
+ update_upload
+ check_upload
+ edit_verify
+ update_verify
+ edit_verify_failed
+ update_verify_failed
+ edit_review
+ update_review
+ ]
+
+ skip_before_action :track_history, only: :new
+
+ def new
+ qualification =
+ application_form.qualifications.find(params[:qualification_id])
+
+ redirect_to [
+ :check_upload,
+ :assessor_interface,
+ application_form,
+ assessment,
+ consent_requests.find_or_create_by(qualification:),
+ ]
+ end
+
+ def edit_request
+ end
+
+ def update_request
+ if consent_requests.present?
+ ActiveRecord::Base.transaction do
+ consent_requests.each do |requestable|
+ RequestRequestable.call(requestable:, user: current_staff)
+ end
+
+ application_form.reload
+
+ ApplicationFormStatusUpdater.call(
+ application_form:,
+ user: current_staff,
+ )
+ end
+
+ TeacherMailer.with(application_form:).consent_requested.deliver_later
+ end
+
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ end
+
+ def edit_upload
+ @form = UploadUnsignedConsentDocumentForm.new(consent_request:)
+ end
+
+ def update_upload
+ @form =
+ UploadUnsignedConsentDocumentForm.new(
+ consent_request:,
+ original_attachment:
+ params.dig(
+ :assessor_interface_upload_unsigned_consent_document_form,
+ :original_attachment,
+ ),
+ )
+
+ if @form.save
+ if (check_path = history_stack.last_path_if_check)
+ redirect_to check_path
+ else
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ end
+ else
+ render :edit_upload, status: :unprocessable_entity
+ end
+ end
+
+ def check_upload
+ unless consent_request.unsigned_consent_document.completed? &&
+ consent_request.unsigned_consent_document.downloadable?
+ history_stack.pop
+
+ redirect_to [
+ :upload,
+ :assessor_interface,
+ application_form,
+ assessment,
+ consent_request,
+ ]
+ end
+ end
+
+ def edit_verify
+ @form =
+ RequestableVerifyPassedForm.new(
+ requestable:,
+ user: current_staff,
+ passed: requestable.verify_passed,
+ received: requestable.received?,
+ )
+ end
+
+ def update_verify
+ passed =
+ params.dig(:assessor_interface_requestable_verify_passed_form, :passed)
+
+ @form =
+ RequestableVerifyPassedForm.new(
+ requestable:,
+ user: current_staff,
+ passed:,
+ received: requestable.received?,
+ )
+
+ if passed == "nil" || @form.save
+ if @form.passed # nil is parsed as true
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ else
+ redirect_to [
+ :verify_failed,
+ :assessor_interface,
+ application_form,
+ assessment,
+ consent_request,
+ ]
+ end
+ else
+ render :edit_verify, status: :unprocessable_entity
+ end
+ end
+
+ def edit_verify_failed
+ @form =
+ RequestableVerifyFailedForm.new(
+ requestable:,
+ user: current_staff,
+ note: requestable.verify_note,
+ )
+ end
+
+ def update_verify_failed
+ @form =
+ RequestableVerifyFailedForm.new(
+ verify_failed_form_params.merge(requestable:, user: current_staff),
+ )
+
+ if @form.save
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ else
+ render :edit_verify_failed, status: :unprocessable_entity
+ end
+ end
def edit_review
@form = RequestableReviewForm.new(requestable:)
@@ -51,12 +225,25 @@ def consent_request
alias_method :requestable, :consent_request
- def set_variables
+ def set_collection_variables
+ authorize %i[assessor_interface consent_request]
+ @consent_requests = consent_requests
+ @application_form = application_form
+ @assessment = assessment
+ end
+
+ def set_member_variables
@consent_request = authorize [:assessor_interface, consent_request]
@application_form = application_form
@assessment = assessment
end
+ def verify_failed_form_params
+ params.require(:assessor_interface_requestable_verify_failed_form).permit(
+ :note,
+ )
+ end
+
def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
:passed,
diff --git a/app/controllers/assessor_interface/documents_controller.rb b/app/controllers/assessor_interface/documents_controller.rb
index 023f5f43c7..7018540224 100644
--- a/app/controllers/assessor_interface/documents_controller.rb
+++ b/app/controllers/assessor_interface/documents_controller.rb
@@ -13,7 +13,7 @@ class DocumentsController < BaseController
def show_pdf
authorize %i[assessor_interface application_form]
- unless all_uploads_downloadable?
+ unless document.downloadable?
render "shared/malware_scan"
return
end
@@ -32,9 +32,5 @@ def show_pdf
def document
@document ||= Document.find(params[:id])
end
-
- def all_uploads_downloadable?
- document.uploads.all? { |upload| upload_downloadable?(upload) }
- end
end
end
diff --git a/app/controllers/assessor_interface/professional_standing_requests_controller.rb b/app/controllers/assessor_interface/professional_standing_requests_controller.rb
index 7d75da76d7..00f0f9bc29 100644
--- a/app/controllers/assessor_interface/professional_standing_requests_controller.rb
+++ b/app/controllers/assessor_interface/professional_standing_requests_controller.rb
@@ -100,14 +100,25 @@ def edit_verify
user: current_staff,
passed: requestable.verify_passed,
received:
- requestable.verify_passed == false ? requestable.received? : nil,
+ (requestable.received? if requestable.verify_passed == false),
)
end
def update_verify
@form =
RequestableVerifyPassedForm.new(
- verify_passed_form_params.merge(requestable:, user: current_staff),
+ requestable:,
+ user: current_staff,
+ passed:
+ params.dig(
+ :assessor_interface_requestable_verify_passed_form,
+ :passed,
+ ),
+ received:
+ params.dig(
+ :assessor_interface_requestable_verify_passed_form,
+ :received,
+ ),
)
if @form.save
@@ -180,13 +191,6 @@ def review_form_params
)
end
- def verify_passed_form_params
- params.require(:assessor_interface_requestable_verify_passed_form).permit(
- :passed,
- :received,
- )
- end
-
def verify_failed_form_params
params.require(:assessor_interface_requestable_verify_failed_form).permit(
:note,
diff --git a/app/controllers/assessor_interface/qualification_requests_controller.rb b/app/controllers/assessor_interface/qualification_requests_controller.rb
index e1fe3bfb9e..4f1a7acbbd 100644
--- a/app/controllers/assessor_interface/qualification_requests_controller.rb
+++ b/app/controllers/assessor_interface/qualification_requests_controller.rb
@@ -4,22 +4,75 @@ module AssessorInterface
class QualificationRequestsController < BaseController
include HistoryTrackable
- before_action :set_collection_variables, only: %i[index consent_letter]
- before_action :set_member_variables, except: %i[index consent_letter]
+ before_action :set_collection_variables,
+ only: %i[
+ index
+ index_consent_methods
+ check_consent_methods
+ edit_unsigned_consent_document
+ update_unsigned_consent_document
+ generate_unsigned_consent_document
+ ]
+ before_action :set_member_variables,
+ only: %i[
+ edit_consent_method
+ update_consent_method
+ edit_request
+ update_request
+ edit_verify
+ update_verify
+ edit_verify_failed
+ update_verify_failed
+ edit_review
+ update_review
+ ]
+ skip_before_action :track_history, only: :generate_unsigned_consent_document
define_history_origin :index
+ define_history_check :check_consent_methods
def index
- authorize %i[assessor_interface qualification_request]
-
- @qualification_requests = qualification_requests
- @application_form = qualification_requests.first.application_form
- @assessment = qualification_requests.first.assessment
+ @view_object =
+ AssessorInterface::QualificationRequestsViewObject.new(
+ application_form:,
+ )
render layout: "full_from_desktop"
end
- def consent_letter
+ def index_consent_methods
+ end
+
+ def check_consent_methods
+ end
+
+ def edit_unsigned_consent_document
+ @form =
+ GenerateUnsignedConsentDocumentForm.new(
+ assessment:,
+ generated: assessment.unsigned_consent_document_generated,
+ )
+ end
+
+ def update_unsigned_consent_document
+ @form =
+ GenerateUnsignedConsentDocumentForm.new(
+ generate_unsigned_consent_document_form_params.merge(assessment:),
+ )
+
+ if @form.save
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ else
+ render :edit_unsigned_consent_document, status: :unprocessable_entity
+ end
+ end
+
+ def generate_unsigned_consent_document
send_data(
ConsentLetter.new(application_form:).render_pdf,
filename: "Apply for QTS - Consent Letter.pdf",
@@ -28,52 +81,157 @@ def consent_letter
)
end
- def edit
- received =
- if requestable.received?
- true
- elsif requestable.expired?
- false
+ def edit_consent_method
+ @form =
+ ConsentMethodForm.new(
+ qualification_request:,
+ consent_method: qualification_request.consent_method,
+ )
+ end
+
+ def update_consent_method
+ @form =
+ ConsentMethodForm.new(
+ consent_method_form_params.merge(qualification_request:),
+ )
+
+ if @form.save
+ if (check_path = history_stack.last_path_if_check)
+ redirect_to check_path
+ elsif (
+ next_qualification_request =
+ qualification_requests[
+ qualification_requests.index(qualification_request) + 1
+ ]
+ )
+ redirect_to [
+ :consent_method,
+ :assessor_interface,
+ application_form,
+ assessment,
+ next_qualification_request,
+ ]
+ else
+ redirect_to [
+ :check_consent_methods,
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
end
+ else
+ render :edit_consent_method, status: :unprocessable_entity
+ end
+ end
- passed = (requestable.review_passed if requestable.received?)
+ def edit_request
+ @form =
+ RequestableRequestForm.new(
+ requestable:,
+ user: current_staff,
+ passed: qualification_request.requested?,
+ )
+ end
- failed =
- if requestable.expired?
- case requestable.review_passed
- when true
- false
- when false
- true
- end
+ def update_request
+ @form =
+ RequestableRequestForm.new(
+ requestable:,
+ user: current_staff,
+ passed:
+ params.dig(:assessor_interface_requestable_request_form, :passed) ||
+ false,
+ )
+
+ if @form.save
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ else
+ render :edit_request, status: :unprocessable_entity
+ end
+ end
+
+ def edit_verify
+ @form =
+ RequestableVerifyPassedForm.new(
+ requestable:,
+ user: current_staff,
+ passed: requestable.verify_passed,
+ received:
+ (requestable.received? if requestable.verify_passed == false),
+ )
+ end
+
+ def update_verify
+ @form =
+ RequestableVerifyPassedForm.new(
+ requestable:,
+ user: current_staff,
+ passed:
+ params.dig(
+ :assessor_interface_requestable_verify_passed_form,
+ :passed,
+ ),
+ received:
+ params.dig(
+ :assessor_interface_requestable_verify_passed_form,
+ :received,
+ ),
+ )
+
+ if @form.save
+ if @form.passed
+ redirect_to [
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ else
+ redirect_to [
+ :verify_failed,
+ :assessor_interface,
+ application_form,
+ assessment,
+ qualification_request,
+ ]
end
+ else
+ render :edit_verify, status: :unprocessable_entity
+ end
+ end
+ def edit_verify_failed
@form =
- QualificationRequestForm.new(
+ RequestableVerifyFailedForm.new(
requestable:,
user: current_staff,
- received:,
- passed:,
- note: requestable.review_note,
- failed:,
+ note: requestable.verify_note,
)
end
- def update
+ def update_verify_failed
@form =
- QualificationRequestForm.new(
- form_params.merge(requestable:, user: current_staff),
+ RequestableVerifyFailedForm.new(
+ requestable:,
+ user: current_staff,
+ **verify_failed_form_params,
)
if @form.save
redirect_to [
:assessor_interface,
- qualification_request.application_form,
- qualification_request.assessment,
+ requestable.application_form,
+ requestable.assessment,
:qualification_requests,
]
else
- render :edit, status: :unprocessable_entity
+ render :edit_verify_failed, status: :unprocessable_entity
end
end
@@ -86,7 +244,7 @@ def update_review
RequestableReviewForm.new(
requestable:,
user: current_staff,
- **requestable_review_form_params,
+ **review_form_params,
)
if @form.save
@@ -138,20 +296,35 @@ def set_member_variables
@assessment = qualification_request.assessment
end
- def form_params
- params.require(:assessor_interface_qualification_request_form).permit(
- :received,
- :passed,
- :note,
- :failed,
+ def generate_unsigned_consent_document_form_params
+ params.require(
+ :assessor_interface_generate_unsigned_consent_document_form,
+ ).permit(:generated)
+ end
+
+ def consent_method_form_params
+ params.require(:assessor_interface_consent_method_form).permit(
+ :consent_method,
)
end
- def requestable_review_form_params
+ def upload_unsigned_consent_document_form_params
+ params.require(
+ :assessor_interface_upload_unsigned_consent_document_form,
+ ).permit(:original_attachment)
+ end
+
+ def review_form_params
params.require(:assessor_interface_requestable_review_form).permit(
:passed,
:note,
)
end
+
+ def verify_failed_form_params
+ params.require(:assessor_interface_requestable_verify_failed_form).permit(
+ :note,
+ )
+ end
end
end
diff --git a/app/controllers/assessor_interface/reference_requests_controller.rb b/app/controllers/assessor_interface/reference_requests_controller.rb
index 9f5e5c4c16..8bcfecfb6d 100644
--- a/app/controllers/assessor_interface/reference_requests_controller.rb
+++ b/app/controllers/assessor_interface/reference_requests_controller.rb
@@ -43,13 +43,20 @@ def edit_verify
requestable:,
user: current_staff,
passed: requestable.verify_passed,
+ received: requestable.received?,
)
end
def update_verify
+ passed =
+ params.dig(:assessor_interface_requestable_verify_passed_form, :passed)
+
@form =
RequestableVerifyPassedForm.new(
- verify_passed_form_params.merge(requestable:, user: current_staff),
+ requestable:,
+ user: current_staff,
+ passed:,
+ received: requestable.received?,
)
if @form.save
@@ -116,12 +123,6 @@ def review_form_params
)
end
- def verify_passed_form_params
- params.require(:assessor_interface_requestable_verify_passed_form).permit(
- :passed,
- )
- end
-
def verify_failed_form_params
params.require(:assessor_interface_requestable_verify_failed_form).permit(
:note,
diff --git a/app/controllers/assessor_interface/uploads_controller.rb b/app/controllers/assessor_interface/uploads_controller.rb
index 880b67d522..d804020c4e 100644
--- a/app/controllers/assessor_interface/uploads_controller.rb
+++ b/app/controllers/assessor_interface/uploads_controller.rb
@@ -13,7 +13,7 @@ class UploadsController < BaseController
def show
authorize %i[assessor_interface application_form]
- if upload_downloadable?(upload)
+ if upload.downloadable?
send_blob_stream(upload.attachment, disposition: :inline)
else
render "shared/malware_scan"
diff --git a/app/controllers/teacher_interface/uploads_controller.rb b/app/controllers/teacher_interface/uploads_controller.rb
index 9a2ca086ff..0adac336f7 100644
--- a/app/controllers/teacher_interface/uploads_controller.rb
+++ b/app/controllers/teacher_interface/uploads_controller.rb
@@ -19,7 +19,7 @@ class UploadsController < BaseController
before_action :load_upload, only: %i[delete destroy show]
def show
- if upload_downloadable?(@upload)
+ if @upload.downloadable?
send_blob_stream(@upload.attachment, disposition: :inline)
else
render "shared/malware_scan"
diff --git a/app/forms/assessor_interface/consent_method_form.rb b/app/forms/assessor_interface/consent_method_form.rb
index bb3e78a796..57639f51b5 100644
--- a/app/forms/assessor_interface/consent_method_form.rb
+++ b/app/forms/assessor_interface/consent_method_form.rb
@@ -10,7 +10,7 @@ class AssessorInterface::ConsentMethodForm
attribute :consent_method
validates :consent_method,
presence: true,
- inclusion: %w[signed_ecctis signed_institution unsigned]
+ inclusion: %w[signed_ecctis signed_institution unsigned none]
def save
return false if invalid?
diff --git a/app/forms/assessor_interface/filter_form.rb b/app/forms/assessor_interface/filter_form.rb
index 543a233fb0..7af948fdf1 100644
--- a/app/forms/assessor_interface/filter_form.rb
+++ b/app/forms/assessor_interface/filter_form.rb
@@ -10,8 +10,8 @@ class AssessorInterface::FilterForm
:location,
:name,
:reference,
+ :show_all,
:stage,
:submitted_at_after,
- :submitted_at_before,
- :show_all
+ :submitted_at_before
end
diff --git a/app/forms/assessor_interface/qualification_request_form.rb b/app/forms/assessor_interface/qualification_request_form.rb
deleted file mode 100644
index df260065f9..0000000000
--- a/app/forms/assessor_interface/qualification_request_form.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-class AssessorInterface::QualificationRequestForm
- include ActiveModel::Model
- include ActiveModel::Attributes
-
- attr_accessor :requestable, :user
- validates :requestable, :user, presence: true
-
- attribute :received, :boolean
- validates :received, inclusion: [true, false]
-
- attribute :passed, :boolean
- validates :passed, inclusion: [true, false], if: :received
-
- attribute :note, :string
- validates :note, presence: true, if: -> { received && passed == false }
-
- attribute :failed, :boolean
- validates :failed, inclusion: [true, false], unless: :received
-
- def save
- return false if invalid?
-
- ActiveRecord::Base.transaction do
- if received && !requestable.received?
- ReceiveRequestable.call(requestable:, user:)
- elsif !received && requestable.received?
- UnreceiveRequestable.call(requestable:, user:)
- end
-
- if review_passed.nil?
- requestable.update!(review_passed: nil, reviewed_at: nil)
- ApplicationFormStatusUpdater.call(application_form:, user:)
- else
- ReviewRequestable.call(
- requestable:,
- user:,
- passed: review_passed,
- note:,
- )
- end
- end
-
- true
- end
-
- delegate :application_form, :assessment, to: :requestable
-
- private
-
- def review_passed
- if received
- passed
- else
- failed ? false : nil
- end
- end
-end
diff --git a/app/forms/assessor_interface/requestable_request_form.rb b/app/forms/assessor_interface/requestable_request_form.rb
index aa49cddc29..c2d33baa66 100644
--- a/app/forms/assessor_interface/requestable_request_form.rb
+++ b/app/forms/assessor_interface/requestable_request_form.rb
@@ -8,14 +8,14 @@ class AssessorInterface::RequestableRequestForm
validates :requestable, :user, presence: true
attribute :passed, :boolean
- validates :passed, inclusion: [true, false]
+ validates :passed, presence: true
delegate :application_form, :assessment, to: :requestable
def save
return false if invalid?
- if passed && !requestable.requested?
+ unless requestable.requested?
RequestRequestable.call(requestable:, user:)
application_form.reload
ApplicationFormStatusUpdater.call(application_form:, user:)
diff --git a/app/forms/assessor_interface/requestable_verify_passed_form.rb b/app/forms/assessor_interface/requestable_verify_passed_form.rb
index 4b763fcdbc..6f6e1ed3be 100644
--- a/app/forms/assessor_interface/requestable_verify_passed_form.rb
+++ b/app/forms/assessor_interface/requestable_verify_passed_form.rb
@@ -11,7 +11,9 @@ class AssessorInterface::RequestableVerifyPassedForm
validates :passed, inclusion: [true, false]
attribute :received, :boolean
- validates :received, inclusion: [nil, true, false]
+ validates :received,
+ inclusion: [true, false],
+ if: -> { !requestable.received? && requestable.expired? && !passed }
def save
return false if invalid?
diff --git a/app/forms/assessor_interface/select_qualifications_form.rb b/app/forms/assessor_interface/select_qualifications_form.rb
index 369122d781..51501794d9 100644
--- a/app/forms/assessor_interface/select_qualifications_form.rb
+++ b/app/forms/assessor_interface/select_qualifications_form.rb
@@ -21,9 +21,12 @@ class AssessorInterface::SelectQualificationsForm
end,
}
+ attribute :qualifications_assessor_note
+
def save
return false unless valid?
session[:qualification_ids] = qualification_ids
+ session[:qualifications_assessor_note] = qualifications_assessor_note
true
end
end
diff --git a/app/helpers/upload_helper.rb b/app/helpers/upload_helper.rb
index 870f1ebef1..a6aa51de6b 100644
--- a/app/helpers/upload_helper.rb
+++ b/app/helpers/upload_helper.rb
@@ -10,14 +10,12 @@ def upload_link_to(upload)
rel: :noopener,
)
- scan_result_problem =
- malware_scanning_enabled? &&
- (upload.scan_result_error? || upload.scan_result_suspect?)
-
- return href unless scan_result_problem
-
- href +
- tag.p("There’s a problem with this file", class: "govuk-error-message")
+ if upload.scan_result_error? || upload.scan_result_suspect?
+ href +
+ tag.p("There’s a problem with this file", class: "govuk-error-message")
+ else
+ href
+ end
end
def upload_path(upload)
@@ -29,12 +27,4 @@ def upload_path(upload)
end
[interface, :application_form, upload.document, upload]
end
-
- def upload_downloadable?(upload)
- !malware_scanning_enabled? || upload.scan_result_clean?
- end
-
- def malware_scanning_enabled?
- FeatureFlags::FeatureFlag.active?(:fetch_malware_scan_result)
- end
end
diff --git a/app/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb
index c1a5964d78..2503a1a5b4 100644
--- a/app/lib/application_form_status_updater.rb
+++ b/app/lib/application_form_status_updater.rb
@@ -52,15 +52,16 @@ def action_required_by
application_form.awarded_at.present?
"none"
elsif dqt_trn_request.present? || assessment_in_review? ||
- overdue_further_information || overdue_qualification ||
- received_further_information || received_qualification
+ overdue_further_information || overdue_ecctis ||
+ received_further_information || received_ecctis
"assessor"
- elsif preliminary_check? || need_to_request_lops? || overdue_consent ||
- received_consent || overdue_lops || received_lops ||
- overdue_reference || received_reference
+ elsif preliminary_check? || need_to_request_lops? ||
+ need_to_request_consent? || need_to_request_ecctis? ||
+ overdue_consent || received_consent || overdue_lops ||
+ received_lops || overdue_reference || received_reference
"admin"
elsif waiting_on_consent || waiting_on_further_information ||
- waiting_on_lops || waiting_on_qualification || waiting_on_reference
+ waiting_on_lops || waiting_on_ecctis || waiting_on_reference
"external"
elsif application_form.submitted_at.present?
"assessor"
@@ -80,11 +81,12 @@ def stage
elsif preliminary_check? ||
(teaching_authority_provides_written_statement && waiting_on_lops)
"pre_assessment"
- elsif assessment_in_verify? || need_to_request_lops? || overdue_consent ||
- overdue_lops || overdue_qualification || overdue_reference ||
- received_consent || received_lops || received_qualification ||
- received_reference || waiting_on_consent || waiting_on_lops ||
- waiting_on_qualification || waiting_on_reference
+ elsif assessment_in_verify? || need_to_request_lops? ||
+ need_to_request_consent? || need_to_request_ecctis? ||
+ overdue_consent || overdue_lops || overdue_ecctis ||
+ overdue_reference || received_consent || received_lops ||
+ received_ecctis || received_reference || waiting_on_consent ||
+ waiting_on_lops || waiting_on_ecctis || waiting_on_reference
"verification"
elsif overdue_further_information || received_further_information ||
waiting_on_further_information ||
@@ -158,15 +160,35 @@ def assessment_in_verify?
def need_to_request_lops?
return false if teaching_authority_provides_written_statement
- professional_standing_requests.any? do |requestable|
- !requestable.requested?
- end
+ professional_standing_requests.any?(&:not_requested?)
+ end
+
+ def need_to_request_consent?
+ (
+ qualification_requests.none?(&:requested?) &&
+ qualification_requests.any?(&:consent_method_unknown?)
+ ) || consent_requests.any?(&:not_requested?)
+ end
+
+ def need_to_request_ecctis?
+ qualification_requests
+ .select(&:not_requested?)
+ .any? do |qualification_request|
+ qualification_request.consent_method_none? ||
+ qualification_request.consent_method_unsigned? ||
+ consent_requests
+ .select(&:verify_passed?)
+ .any? do |consent_request|
+ consent_request.qualification ==
+ qualification_request.qualification
+ end
+ end
end
def requestable_statuses
@requestable_statuses ||=
%w[overdue received waiting_on]
- .product(%w[consent further_information lops qualification reference])
+ .product(%w[consent ecctis further_information lops reference])
.map { |status, requestable| "#{status}_#{requestable}" }
.filter { |column| send(column) }
end
@@ -184,8 +206,8 @@ def overdue_lops
overdue?(requestables: professional_standing_requests)
end
- def overdue_qualification
- overdue?(requestables: qualification_requests.select(&:requested?))
+ def overdue_ecctis
+ overdue?(requestables: qualification_requests)
end
def overdue_reference
@@ -205,7 +227,7 @@ def received_lops
received?(requestables: professional_standing_requests)
end
- def received_qualification
+ def received_ecctis
received?(requestables: qualification_requests)
end
@@ -245,7 +267,7 @@ def waiting_on_lops
waiting_on?(requestables: professional_standing_requests)
end
- def waiting_on_qualification
+ def waiting_on_ecctis
waiting_on?(requestables: qualification_requests)
end
diff --git a/app/lib/consent_letter.rb b/app/lib/consent_letter.rb
index 8fa21b0902..1eb7b899eb 100644
--- a/app/lib/consent_letter.rb
+++ b/app/lib/consent_letter.rb
@@ -5,13 +5,7 @@ class ConsentLetter
def initialize(application_form:)
@application_form = application_form
- @date_of_consent =
- application_form
- .assessment
- .qualification_requests
- .first
- .created_at
- .to_date
+ @date_of_consent = application_form.submitted_at.to_date
end
def render_pdf
@@ -33,7 +27,7 @@ def document
Prawn::Document
.new(margin: MARGIN)
.tap do |pdf|
- pdf.image("public/tra-logo.png", position: :right)
+ pdf.image("public/tra-logo.png", position: :right, scale: 0.6)
pdf.pad(SECTION_PAD) do
pdf.text "By submitting an application to the Apply for qualified teacher status (QTS) in England."
diff --git a/app/lib/filters/show_all_applications.rb b/app/lib/filters/show_all.rb
similarity index 90%
rename from app/lib/filters/show_all_applications.rb
rename to app/lib/filters/show_all.rb
index 8ea22fc03c..b927d3ab69 100644
--- a/app/lib/filters/show_all_applications.rb
+++ b/app/lib/filters/show_all.rb
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Filters
- class ShowAllApplications < Base
+ class ShowAll < Base
def apply
unless show_all?
ninety_days_ago = 90.days.ago
diff --git a/app/lib/history_stack.rb b/app/lib/history_stack.rb
index 7961210449..e06abd5da0 100644
--- a/app/lib/history_stack.rb
+++ b/app/lib/history_stack.rb
@@ -48,18 +48,19 @@ def last_entry
apply_to_stack(&:second_to_last)
end
- def last_path_if_check(identifier: nil)
+ def last_entry_is_check?(identifier: nil)
entry = last_entry
- return nil unless entry
+ return false unless entry
- is_check =
- if identifier.present?
- entry[:check] == true || entry[:check] == identifier
- else
- entry[:check].present?
- end
+ if identifier.present?
+ entry[:check] == true || entry[:check] == identifier
+ else
+ entry[:check].present?
+ end
+ end
- entry[:path] if is_check
+ def last_path_if_check(identifier: nil)
+ last_entry[:path] if last_entry_is_check?(identifier:)
end
private
diff --git a/app/models/assessment.rb b/app/models/assessment.rb
index 3e1e4a3652..de733c78fe 100644
--- a/app/models/assessment.rb
+++ b/app/models/assessment.rb
@@ -120,19 +120,6 @@ def can_decline?
elsif request_further_information?
all_further_information_requests_reviewed? &&
any_further_information_requests_failed?
- elsif verify?
- if professional_standing_request_verify_failed? ||
- any_reference_requests_verify_failed? ||
- any_consent_requests_verify_failed?
- return false
- end
-
- return false unless all_consent_requests_verified?
- return false unless all_qualification_requests_reviewed?
- return false unless all_reference_requests_verified?
- return false unless professional_standing_request_verified?
-
- any_qualification_requests_review_failed?
elsif review?
return false unless all_consent_requests_reviewed?
return false unless all_qualification_requests_reviewed?
@@ -163,12 +150,14 @@ def can_review?
return false unless application_form.created_under_new_regulations?
return false unless all_consent_requests_verified?
- return false unless all_qualification_requests_reviewed?
return false unless all_reference_requests_verified?
return false unless professional_standing_request_verified?
- any_consent_requests_verify_failed? ||
- any_qualification_requests_verify_failed? ||
+ # We can skip qualifications if consent has been rejected
+ return true if any_consent_requests_verify_failed?
+ return false unless all_qualification_requests_verified?
+
+ any_qualification_requests_verify_failed? ||
any_reference_requests_verify_failed? ||
professional_standing_request_verify_failed?
end
@@ -213,10 +202,6 @@ def any_not_preliminary_section_finished?
sections.not_preliminary.any?(&:finished?)
end
- def all_reference_requests_verified?
- reference_requests.all?(&:verified?)
- end
-
def enough_reference_requests_verify_passed?
return true if reference_requests.empty?
return false if any_reference_requests_verify_failed?
@@ -287,14 +272,18 @@ def enough_reference_requests_review_passed?
).enough_for_submission?
end
- def any_reference_requests_verify_failed?
- reference_requests.any?(&:verify_failed?)
- end
-
def any_reference_requests_review_failed?
reference_requests.any?(&:review_failed?)
end
+ def all_reference_requests_verified?
+ reference_requests.all?(&:verified?)
+ end
+
+ def any_reference_requests_verify_failed?
+ reference_requests.any?(&:verify_failed?)
+ end
+
def all_consent_requests_reviewed?
consent_requests.where(verify_passed: false).all?(&:reviewed?)
end
@@ -304,9 +293,7 @@ def any_consent_requests_review_failed?
end
def all_consent_requests_review_passed?
- consent_requests.all? do |consent_request|
- consent_request.verify_passed? || consent_request.review_passed?
- end
+ consent_requests.all?(&:review_or_verify_passed?)
end
def all_consent_requests_verified?
@@ -322,18 +309,16 @@ def all_consent_requests_verify_passed?
end
def all_qualification_requests_reviewed?
- # we can skip qualifications if consent is invalid
- if all_consent_requests_verified? && any_consent_requests_verify_failed?
- return true
- end
- qualification_requests.all?(&:reviewed?)
+ qualification_requests.where(verify_passed: false).all?(&:reviewed?)
end
def all_qualification_requests_review_passed?
if application_form.reduced_evidence_accepted
- qualification_requests.all?(&:reviewed?)
+ qualification_requests.all? do |qualification_request|
+ qualification_request.reviewed? || qualification_request.verified?
+ end
else
- qualification_requests.all?(&:review_passed?)
+ qualification_requests.all?(&:review_or_verify_passed?)
end
end
@@ -341,6 +326,18 @@ def any_qualification_requests_review_failed?
qualification_requests.any?(&:review_failed?)
end
+ def all_qualification_requests_verified?
+ qualification_requests.all?(&:verified?)
+ end
+
+ def all_qualification_requests_verify_passed?
+ if application_form.reduced_evidence_accepted
+ qualification_requests.all?(&:verified?)
+ else
+ qualification_requests.all?(&:verify_passed?)
+ end
+ end
+
def any_qualification_requests_verify_failed?
qualification_requests.any?(&:verify_failed?)
end
@@ -356,8 +353,7 @@ def professional_standing_request_reviewed?
def professional_standing_request_review_passed?
if professional_standing_request_part_of_verification?
- professional_standing_request.verify_passed? ||
- professional_standing_request.review_passed?
+ professional_standing_request.review_or_verify_passed?
else
true
end
diff --git a/app/models/concerns/requestable.rb b/app/models/concerns/requestable.rb
index 582b412781..bf4b3297cd 100644
--- a/app/models/concerns/requestable.rb
+++ b/app/models/concerns/requestable.rb
@@ -9,6 +9,7 @@ module Requestable
belongs_to :assessment
scope :requested, -> { where.not(requested_at: nil) }
+ scope :not_requested, -> { where(requested_at: nil) }
scope :received, -> { where.not(received_at: nil) }
scope :not_received, -> { where(received_at: nil) }
scope :respondable,
@@ -26,6 +27,10 @@ def requested?
requested_at != nil
end
+ def not_requested?
+ requested_at.nil?
+ end
+
def received!
update!(received_at: Time.zone.now)
end
@@ -58,11 +63,15 @@ def verify_failed?
try(:verify_passed) == false
end
- def status(not_requested: "not_started")
- if review_passed? || review_failed?
- review_status
- elsif verify_passed?
- "accepted"
+ def review_or_verify_passed?
+ verify_passed? || review_passed?
+ end
+
+ def status
+ if review_passed? || verify_passed?
+ "completed"
+ elsif review_failed?
+ "rejected"
elsif verify_failed?
"review"
elsif received? && expired?
@@ -74,7 +83,7 @@ def status(not_requested: "not_started")
elsif requested?
"waiting_on"
else
- not_requested
+ "cannot_start"
end
end
diff --git a/app/models/document.rb b/app/models/document.rb
index 2c1230c3fc..246e333745 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -71,6 +71,10 @@ def optional?
written_statement? && application_form.written_statement_optional
end
+ def downloadable?
+ uploads.all?(&:downloadable?)
+ end
+
def for_further_information_request?
documentable.is_a?(FurtherInformationRequestItem)
end
diff --git a/app/models/qualification_request.rb b/app/models/qualification_request.rb
index 3bc858577a..d6c98a4487 100644
--- a/app/models/qualification_request.rb
+++ b/app/models/qualification_request.rb
@@ -37,6 +37,7 @@ class QualificationRequest < ApplicationRecord
belongs_to :qualification
enum consent_method: {
+ none: "none",
signed_ecctis: "signed_ecctis",
signed_institution: "signed_institution",
unknown: "unknown",
@@ -49,6 +50,9 @@ class QualificationRequest < ApplicationRecord
scope :order_by_user,
-> { joins(:qualification).order("qualifications.created_at": :asc) }
+ scope :consent_method_signed,
+ -> { where(consent_method: %w[signed_ecctis signed_institution]) }
+
def expires_after
6.weeks
end
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 6fdb102746..adb18dc467 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -50,4 +50,9 @@ def url
def is_pdf?
attachment.blob.content_type == "application/pdf"
end
+
+ def downloadable?
+ !FeatureFlags::FeatureFlag.active?(:fetch_malware_scan_result) ||
+ scan_result_clean?
+ end
end
diff --git a/app/policies/assessor_interface/consent_request_policy.rb b/app/policies/assessor_interface/consent_request_policy.rb
index 1f05947d58..eff06a2a1f 100644
--- a/app/policies/assessor_interface/consent_request_policy.rb
+++ b/app/policies/assessor_interface/consent_request_policy.rb
@@ -1,6 +1,35 @@
# frozen_string_literal: true
class AssessorInterface::ConsentRequestPolicy < ApplicationPolicy
+ def create?
+ user.verify_permission
+ end
+
+ def update_request?
+ user.verify_permission
+ end
+
+ alias_method :edit_request?, :update_request?
+
+ def update_upload?
+ user.verify_permission
+ end
+
+ alias_method :edit_upload?, :update_upload?
+ alias_method :check_upload?, :update_upload?
+
+ def update_verify?
+ user.verify_permission
+ end
+
+ alias_method :edit_verify?, :update_verify?
+
+ def update_verify_failed?
+ user.verify_permission
+ end
+
+ alias_method :edit_verify_failed?, :update_verify_failed?
+
def update_review?
user.assess_permission
end
diff --git a/app/policies/assessor_interface/qualification_request_policy.rb b/app/policies/assessor_interface/qualification_request_policy.rb
index 8377ee4564..2208c11598 100644
--- a/app/policies/assessor_interface/qualification_request_policy.rb
+++ b/app/policies/assessor_interface/qualification_request_policy.rb
@@ -5,14 +5,49 @@ def index?
true
end
- def consent_letter?
+ def index_consent_methods?
user.verify_permission
end
- def update?
- user.assess_permission
+ def check_consent_methods?
+ user.verify_permission
end
+ def update_unsigned_consent_document?
+ user.verify_permission
+ end
+
+ alias_method :edit_unsigned_consent_document?,
+ :update_unsigned_consent_document?
+
+ def generate_unsigned_consent_document?
+ user.verify_permission
+ end
+
+ def update_consent_method?
+ user.verify_permission
+ end
+
+ alias_method :edit_consent_method?, :update_consent_method?
+
+ def update_request?
+ user.verify_permission
+ end
+
+ alias_method :edit_request?, :update_request?
+
+ def update_verify?
+ user.verify_permission
+ end
+
+ alias_method :edit_verify?, :update_verify?
+
+ def update_verify_failed?
+ user.verify_permission
+ end
+
+ alias_method :edit_verify_failed?, :update_verify_failed?
+
def update_review?
user.assess_permission
end
diff --git a/app/services/verify_assessment.rb b/app/services/verify_assessment.rb
index 07ccc09360..5971b62185 100644
--- a/app/services/verify_assessment.rb
+++ b/app/services/verify_assessment.rb
@@ -8,12 +8,14 @@ def initialize(
user:,
professional_standing:,
qualifications:,
+ qualifications_assessor_note:,
work_histories:
)
@assessment = assessment
@user = user
@professional_standing = professional_standing
@qualifications = qualifications
+ @qualifications_assessor_note = qualifications_assessor_note
@work_histories = work_histories
end
@@ -22,6 +24,7 @@ def call
reference_requests =
ActiveRecord::Base.transaction do
+ assessment.qualifications_assessor_note = qualifications_assessor_note
assessment.verify!
create_professional_standing_request
@@ -51,6 +54,7 @@ class AlreadyVerified < StandardError
:user,
:professional_standing,
:qualifications,
+ :qualifications_assessor_note,
:work_histories
delegate :application_form, to: :assessment
@@ -64,9 +68,7 @@ def create_professional_standing_request
def create_qualification_requests
qualifications.map do |qualification|
- QualificationRequest
- .create!(assessment:, qualification:)
- .tap { |requestable| RequestRequestable.call(requestable:, user:) }
+ QualificationRequest.create!(assessment:, qualification:)
end
end
diff --git a/app/view_objects/assessor_interface/application_forms_index_view_object.rb b/app/view_objects/assessor_interface/application_forms_index_view_object.rb
index 6d510c747a..ec8d783d99 100644
--- a/app/view_objects/assessor_interface/application_forms_index_view_object.rb
+++ b/app/view_objects/assessor_interface/application_forms_index_view_object.rb
@@ -23,6 +23,7 @@ def filter_form
def assessor_filter_options
ApplicationForm
+ .submitted
.joins(:assessor)
.pluck(Arel.sql("DISTINCT ON(assessor_id) assessor_id"), "staff.name")
.sort_by { |_id, name| name }
@@ -74,7 +75,7 @@ def application_forms_without_counted_filters
::Filters::Email,
::Filters::Reference,
::Filters::SubmittedAt,
- ::Filters::ShowAllApplications,
+ ::Filters::ShowAll,
]
filters.reduce(
ApplicationForm.includes(region: :country).submitted,
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 94661a55f7..1dc345beec 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
@@ -292,10 +292,7 @@ def qualification_requests_task_list_item
assessment,
:qualification_requests,
],
- status:
- requestables_task_item_status(
- qualification_requests.reject(&:reviewed?),
- ),
+ status: qualification_requests_task_item_status,
}
end
@@ -336,10 +333,7 @@ def professional_standing_request_task_list_item
assessment,
:professional_standing_request,
],
- status:
- requestables_task_item_status(
- [professional_standing_request].reject(&:verified?),
- ),
+ status: requestables_task_item_status([professional_standing_request]),
}
end
@@ -401,7 +395,8 @@ def review_verifications_task_list_item
!teaching_authority_provides_written_statement &&
professional_standing_request&.reviewed?
) || consent_requests.any?(:reviewed?) ||
- reference_requests.any?(:reviewed?)
+ reference_requests.any?(:reviewed?) ||
+ qualification_requests.any?(:reviewed?)
:in_progress
else
:not_started
@@ -450,13 +445,15 @@ def initial_assessment_recommendation_complete?
end
def requestables_task_item_status(requestables)
- if requestables.empty?
+ unverified_requestables = requestables.reject(&:verified?)
+
+ if unverified_requestables.empty?
"completed"
- elsif requestables.any?(&:expired?)
+ elsif unverified_requestables.any?(&:expired?)
"overdue"
- elsif requestables.any?(&:received?)
+ elsif unverified_requestables.any?(&:received?)
"received"
- elsif requestables.any?(&:requested?)
+ elsif unverified_requestables.any?(&:requested?)
"waiting_on"
else
"not_started"
@@ -467,7 +464,34 @@ def reference_requests_task_item_status
if assessment.enough_reference_requests_verify_passed?
"completed"
else
- requestables_task_item_status(reference_requests.reject(&:verified?))
+ requestables_task_item_status(reference_requests)
+ end
+ end
+
+ def qualification_requests_task_item_status
+ requestables =
+ qualification_requests.map do |qualification_request|
+ consent_request =
+ consent_requests.find_by(
+ qualification: qualification_request.qualification,
+ )
+
+ if consent_request.nil? || consent_request.verify_passed?
+ qualification_request
+ else
+ consent_request
+ end
+ end
+
+ status = requestables_task_item_status(requestables)
+
+ return status if status != "not_started"
+
+ if qualification_requests.consent_method_unknown.count ==
+ qualification_requests.count
+ "not_started"
+ else
+ "in_progress"
end
end
diff --git a/app/view_objects/assessor_interface/qualification_requests_view_object.rb b/app/view_objects/assessor_interface/qualification_requests_view_object.rb
index 84829c89ed..29a4d01160 100644
--- a/app/view_objects/assessor_interface/qualification_requests_view_object.rb
+++ b/app/view_objects/assessor_interface/qualification_requests_view_object.rb
@@ -29,6 +29,11 @@ def all_task_items
end
end
+ def all_consent_methods_selected?
+ qualification_requests.none?(&:consent_method_unknown?) ||
+ qualification_requests.requested.exists?
+ end
+
def show_individual_task_items?
all_consent_methods_selected? && qualification_requests.count > 1
end
@@ -44,13 +49,8 @@ def consent_requests
end
def individual_task_items_for(qualification_request:)
- return [] if qualification_request.consent_method_unknown?
-
- if qualification_request.consent_method_unsigned?
- unsigned_consent_method_task_items(qualification_request)
- else
- signed_consent_method_task_items(qualification_request)
- end + ecctis_task_items(qualification_request)
+ consent_task_items(qualification_request) +
+ ecctis_task_items(qualification_request)
end
private
@@ -59,21 +59,38 @@ def individual_task_items_for(qualification_request:)
delegate :assessment, to: :application_form
- def all_consent_methods_selected?
- qualification_requests.none?(&:consent_method_unknown?)
- end
-
def check_consent_method_task_item
- status =
- if qualification_requests.all?(&:consent_method_unknown?)
- "not_started"
- elsif all_consent_methods_selected?
- "completed"
- else
- "in_progress"
- end
-
- { name: "Check and select consent method", link: "#", status: }
+ cannot_change =
+ assessment.unsigned_consent_document_generated ||
+ consent_requests.exists? || qualification_requests.requested.exists?
+
+ {
+ name: "Check and select consent method",
+ link:
+ unless cannot_change
+ [
+ (
+ if all_consent_methods_selected?
+ :check_consent_methods
+ else
+ :consent_methods
+ end
+ ),
+ :assessor_interface,
+ application_form,
+ assessment,
+ :qualification_requests,
+ ]
+ end,
+ status:
+ if all_consent_methods_selected?
+ "completed"
+ elsif qualification_requests.all?(&:consent_method_unknown?)
+ "not_started"
+ else
+ "in_progress"
+ end,
+ }
end
def generate_consent_document_in_all_qualifications?
@@ -85,7 +102,7 @@ def generate_consent_document_task_item
{
name: "Generate consent document",
link: [
- :consent_letter,
+ :unsigned_consent_document,
:assessor_interface,
application_form,
assessment,
@@ -102,27 +119,37 @@ def generate_consent_document_task_item
}
end
- def unsigned_consent_method_task_items(_qualification_request)
- if generate_consent_document_in_all_qualifications?
- []
- else
- [generate_consent_document_task_item]
- end
- end
-
def send_consent_document_in_all_qualifications?
- all_consent_methods_selected? && consent_requests.count >= 2
+ all_consent_methods_selected? &&
+ qualification_requests.consent_method_signed.count >= 2
end
def send_consent_document_task_item
+ all_documents_completed =
+ qualification_requests.consent_method_signed.count ==
+ consent_requests.count &&
+ consent_requests
+ .map(&:unsigned_consent_document)
+ .all? { |document| document.completed? && document.downloadable? }
+
+ all_consents_requested = consent_requests.all?(&:requested?)
+
{
- name: "Send consent document to applicant",
- link: "#",
+ name:
+ "Send consent #{"document".pluralize(consent_requests.count)} to applicant",
+ link:
+ if all_documents_completed && !all_consents_requested
+ [
+ :request,
+ :assessor_interface,
+ application_form,
+ assessment,
+ :consent_requests,
+ ]
+ end,
status:
- if consent_requests.map(&:unsigned_consent_document).all?(
- &:completed?
- )
- consent_requests.all?(&:requested?) ? "completed" : "not_started"
+ if all_documents_completed
+ all_consents_requested ? "completed" : "not_started"
else
"cannot_start"
end,
@@ -131,18 +158,41 @@ def send_consent_document_task_item
def signed_consent_method_task_items(qualification_request)
consent_request =
- consent_requests.find_by!(
+ consent_requests.find_by(
qualification: qualification_request.qualification,
)
[
{
name: "Upload consent document",
- link: "#",
+ link:
+ if consent_request.nil?
+ Rails
+ .application
+ .routes
+ .url_helpers
+ .new_assessor_interface_application_form_assessment_consent_request_path(
+ application_form,
+ assessment,
+ qualification_id: qualification_request.qualification.id,
+ )
+ elsif !consent_request.requested?
+ [
+ :check_upload,
+ :assessor_interface,
+ application_form,
+ assessment,
+ consent_request,
+ ]
+ end,
status:
(
- if consent_request.unsigned_consent_document.completed?
- "completed"
+ if consent_request&.unsigned_consent_document&.completed?
+ if consent_request&.unsigned_consent_document&.downloadable?
+ "completed"
+ else
+ "in_progress"
+ end
else
"not_started"
end
@@ -153,42 +203,87 @@ def signed_consent_method_task_items(qualification_request)
end,
{
name: "Record applicant response",
- link: "#",
- status: consent_request.status(not_requested: "cannot_start"),
+ link:
+ if consent_request&.requested?
+ [
+ :verify,
+ :assessor_interface,
+ application_form,
+ assessment,
+ consent_request,
+ ]
+ end,
+ status: consent_request&.status || "cannot_start",
},
- ]
+ ].compact
+ end
+
+ def consent_task_items(qualification_request)
+ if qualification_request.consent_method_unsigned? &&
+ !generate_consent_document_in_all_qualifications?
+ [generate_consent_document_task_item]
+ elsif qualification_request.consent_method_signed?
+ signed_consent_method_task_items(qualification_request)
+ else
+ []
+ end
end
def ecctis_task_items(qualification_request)
+ if qualification_request.consent_method_unknown? &&
+ !qualification_request.requested?
+ return []
+ end
+
can_start =
- (
- qualification_request.consent_method_unsigned? &&
- assessment.unsigned_consent_document_generated
- ) ||
- consent_requests.verified.exists?(
- qualification: qualification_request.qualification,
+ qualification_request.consent_method_none? ||
+ (
+ qualification_request.consent_method_unsigned? &&
+ assessment.unsigned_consent_document_generated
+ ) ||
+ (
+ qualification_request.consent_method_signed? &&
+ consent_requests.exists?(
+ verify_passed: true,
+ qualification: qualification_request.qualification,
+ )
)
[
{
name: "Request Ecctis verification",
- link: "#",
+ link:
+ if can_start && !qualification_request.requested?
+ [
+ :request,
+ :assessor_interface,
+ application_form,
+ assessment,
+ qualification_request,
+ ]
+ end,
status:
- if can_start
- qualification_request.requested? ? "completed" : "not_started"
+ if qualification_request.requested?
+ "completed"
+ elsif can_start
+ "not_started"
else
"cannot_start"
end,
},
{
name: "Record Ecctis response",
- link: "#",
- status:
- if can_start && qualification_request.requested?
- qualification_request.received? ? "completed" : "not_started"
- else
- "cannot_start"
+ link:
+ if qualification_request.requested?
+ [
+ :verify,
+ :assessor_interface,
+ application_form,
+ assessment,
+ qualification_request,
+ ]
end,
+ status: qualification_request.status,
},
]
end
diff --git a/app/views/assessor_interface/application_forms/index.html.erb b/app/views/assessor_interface/application_forms/index.html.erb
index c68f967e09..12deaa73b7 100644
--- a/app/views/assessor_interface/application_forms/index.html.erb
+++ b/app/views/assessor_interface/application_forms/index.html.erb
@@ -63,11 +63,11 @@
<% end %>
<% end %>
-
- <% if FeatureFlags::FeatureFlag.active?(:show_all_applicants_filter) %>
+
+ <% if FeatureFlags::FeatureFlag.active?(:show_all_applications_filter) %>
References | +Qualifications | |
---|---|---|
+ <%= qualification_title(consent_request.qualification) %> +Internal note+ <%= simple_format consent_request.verify_note %> + |
+
+ + <%= render(StatusTag::Component.new("review")) %> + | +|
@@ -47,7 +61,7 @@ | - <%= render(StatusTag::Component.new(qualification_request.status)) %> + <%= render(StatusTag::Component.new("review")) %> | - <%= render(StatusTag::Component.new(reference_request.status)) %> + <%= render(StatusTag::Component.new("review")) %> | <% end %> diff --git a/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb b/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb index 5bbf831226..2d741f4271 100644 --- a/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb +++ b/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb @@ -1,25 +1,24 @@ -<% content_for :page_title, title_with_error_prefix(t(".heading"), error: @form.errors.any?) %> -<% content_for :back_link_url, back_history_path(default: verify_qualifications_assessor_interface_application_form_assessment_assessment_recommendation_verify_path) %> +<% title = "Verify qualifications" %> + +<% content_for :page_title, title_with_error_prefix(title, error: @form.errors.any?) %> +<% content_for :back_link_url, back_history_path(default: verify_qualifications_assessor_interface_application_form_assessment_assessment_recommendation_verify_path(@application_form, @assessment)) %> <%= form_with model: @form, url: [:qualification_requests, :assessor_interface, @application_form, @assessment, :assessment_recommendation_verify] do |f| %> <%= f.govuk_error_summary %> -