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 Oct 15, 2023
1 parent d4439ae commit 7155985
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 29 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
61 changes: 46 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,8 +113,6 @@ 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?
else
Expand All @@ -134,15 +132,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 +213,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 +230,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 +242,49 @@ 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_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
2 changes: 1 addition & 1 deletion spec/models/assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@

context "when awarded pending verification" do
before { assessment.verify! }
it { is_expected.to be true }
it { is_expected.to be false }
end
end

Expand Down

0 comments on commit 7155985

Please sign in to comment.