Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add review assessment recommendation #1734

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,23 @@ 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,
inclusion: {
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
Expand All @@ -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
Expand All @@ -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? ||
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?

Expand Down
5 changes: 4 additions & 1 deletion config/locales/assessor_interface.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ 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
qualification_requests: Record qualifications responses
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:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/helpers.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading
Loading