Skip to content

Commit

Permalink
Allow sending an assessment to review
Browse files Browse the repository at this point in the history
This makes it possible to send an assessment to review if the LoPS is
unable to be verified by an admin user.
  • Loading branch information
thomasleese committed Nov 3, 2023
1 parent bdea967 commit ee553c2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

module AssessorInterface
class AssessmentRecommendationReviewController < BaseController
before_action :authorize_assessor
before_action :ensure_can_review
before_action :load_assessment_and_application_form

def edit
authorize %i[assessor_interface assessment_recommendation]

@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed?
end

def update
authorize %i[assessor_interface assessment_recommendation]

ActiveRecord::Base.transaction do
assessment.review!
ApplicationFormStatusUpdater.call(
Expand Down
7 changes: 1 addition & 6 deletions app/lib/application_form_status_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ def received_further_information

def received_lops
return false if teaching_authority_provides_written_statement

professional_standing_requests
.reject(&:verified?)
.any? do |requestable|
requestable.received? || requestable.ready_for_review
end
received?(requestables: professional_standing_requests)
end

def received_qualification
Expand Down
73 changes: 58 additions & 15 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def can_award?
elsif verify?
enough_reference_requests_review_passed? &&
all_qualification_requests_review_passed? &&
professional_standing_request_review_passed?
professional_standing_request_verify_passed?
elsif review?
professional_standing_request_review_passed?
else
Expand All @@ -113,10 +113,12 @@ def can_decline?
(all_sections_finished? && any_section_failed? && any_section_declines?)
elsif request_further_information?
any_further_information_request_failed?
elsif verify?
true # TODO: check the state of verification requests
elsif review?
professional_standing_request_review_failed?
elsif verify?
enough_reference_requests_reviewed? &&
all_qualification_requests_reviewed? &&
professional_standing_request_verified? && !can_review? && !can_award?
else
false
end
Expand All @@ -134,15 +136,16 @@ def can_request_further_information?

def can_review?
return false unless application_form.created_under_new_regulations?

return false unless verify?
return false if skip_verification?

false
enough_reference_requests_reviewed? &&
all_qualification_requests_reviewed? &&
professional_standing_request_verify_failed?
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?
Expand Down Expand Up @@ -214,6 +217,7 @@ def any_further_information_request_failed?
end

def enough_reference_requests_review_passed?
return true if reference_requests.empty?
return false unless references_verified

months_count =
Expand All @@ -230,6 +234,10 @@ def enough_reference_requests_review_passed?
months_count >= 9
end

def enough_reference_requests_reviewed?
references_verified || reference_requests.empty?
end

def all_qualification_requests_review_passed?
if qualification_requests.present?
qualification_requests.all?(&:review_passed?)
Expand All @@ -238,22 +246,57 @@ def all_qualification_requests_review_passed?
end
end

def all_qualification_requests_reviewed?
if qualification_requests.present?
qualification_requests.all?(&:reviewed?)
else
true
end
end

def professional_standing_request_review_passed?
if professional_standing_request_part_of_verification?
professional_standing_request.review_passed?
else
true
end
end

def professional_standing_request_verified?
if professional_standing_request_part_of_verification?
professional_standing_request.verified?
else
true
end
end

def professional_standing_request_review_failed?
if application_form.teaching_authority_provides_written_statement
return true
if professional_standing_request_part_of_verification?
professional_standing_request.review_failed?
else
false
end
return true if professional_standing_request.nil?
end

professional_standing_request.review_failed?
def professional_standing_request_verify_passed?
if professional_standing_request_part_of_verification?
professional_standing_request.verify_passed?
else
true
end
end

def professional_standing_request_review_passed?
if application_form.teaching_authority_provides_written_statement
return true
def professional_standing_request_verify_failed?
if professional_standing_request_part_of_verification?
professional_standing_request.verify_failed?
else
false
end
return true if professional_standing_request.nil?
end

professional_standing_request.review_passed?
def professional_standing_request_part_of_verification?
!application_form.teaching_authority_provides_written_statement &&
professional_standing_request.present?
end

def skip_verification?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,10 @@ def review_verifications_task_list_item
:review_verifications,
],
status:
if assessment.recommendable?
if assessment.completed? || assessment.recommendable?
:completed
elsif (
!teaching_authority_provides_written_statement &&
professional_standing_request&.reviewed?
) || qualification_requests.any?(&:reviewed?) ||
reference_requests.any?(&:reviewed?)
elsif !teaching_authority_provides_written_statement &&
professional_standing_request&.reviewed?
:in_progress
else
:not_started
Expand Down

0 comments on commit ee553c2

Please sign in to comment.