diff --git a/app/controllers/teacher_interface/qualification_requests_controller.rb b/app/controllers/teacher_interface/qualification_requests_controller.rb
index df386ba434..e4f0958593 100644
--- a/app/controllers/teacher_interface/qualification_requests_controller.rb
+++ b/app/controllers/teacher_interface/qualification_requests_controller.rb
@@ -8,6 +8,7 @@ class QualificationRequestsController < BaseController
define_history_reset :index
def index
+ @view_object = QualificationRequestsViewObject.new(application_form:)
end
end
end
diff --git a/app/lib/document_continue_redirection.rb b/app/lib/document_continue_redirection.rb
index 2081847c57..bd3287fdf6 100644
--- a/app/lib/document_continue_redirection.rb
+++ b/app/lib/document_continue_redirection.rb
@@ -69,6 +69,6 @@ def further_information_request_url
end
def qualification_request_url
- [:teacher_interface, :application_form, documentable]
+ %i[teacher_interface application_form qualification_requests]
end
end
diff --git a/app/models/qualification_request.rb b/app/models/qualification_request.rb
index e94470ec62..b349d436ef 100644
--- a/app/models/qualification_request.rb
+++ b/app/models/qualification_request.rb
@@ -50,6 +50,7 @@ class QualificationRequest < ApplicationRecord
consent_required
.consent_requested
.where(consent_received_at: nil)
+ .joins(assessment: :application_form)
.merge(ApplicationForm.assessable)
end
diff --git a/app/view_objects/teacher_interface/application_form_view_object.rb b/app/view_objects/teacher_interface/application_form_view_object.rb
index f50b93875a..0f1b21a954 100644
--- a/app/view_objects/teacher_interface/application_form_view_object.rb
+++ b/app/view_objects/teacher_interface/application_form_view_object.rb
@@ -140,10 +140,7 @@ def request_professional_standing_certificate?
def request_qualification_consent?
return false if assessment.nil?
- qualification_requests
- .joins(assessment: :application_form)
- .consent_respondable
- .exists?
+ qualification_requests.consent_respondable.exists?
end
def show_work_history_under_submission_banner?
diff --git a/app/view_objects/teacher_interface/qualification_requests_view_object.rb b/app/view_objects/teacher_interface/qualification_requests_view_object.rb
new file mode 100644
index 0000000000..fc346c51fd
--- /dev/null
+++ b/app/view_objects/teacher_interface/qualification_requests_view_object.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+module TeacherInterface
+ class QualificationRequestsViewObject
+ include QualificationHelper
+
+ def initialize(application_form:)
+ @application_form = application_form
+ end
+
+ def task_list_sections
+ qualification_requests.map do |qualification_request|
+ {
+ title: qualification_title(qualification_request.qualification),
+ items: task_list_items(qualification_request),
+ }
+ end
+ end
+
+ private
+
+ attr_reader :application_form
+
+ def qualification_requests
+ @qualification_requests ||=
+ application_form
+ .assessment
+ .qualification_requests
+ .order_by_user
+ .consent_respondable
+ end
+
+ def task_list_items(qualification_request)
+ institution_name = qualification_request.qualification.institution_name
+
+ [
+ {
+ link: [
+ :download,
+ :teacher_interface,
+ :application_form,
+ qualification_request,
+ ],
+ name: "Download #{institution_name} consent document",
+ status:
+ download_unsigned_consent_document_status(qualification_request),
+ },
+ {
+ link: [
+ :teacher_interface,
+ :application_form,
+ qualification_request.signed_consent_document,
+ ],
+ name: "Upload #{institution_name} consent document",
+ status: upload_signed_consent_document_status(qualification_request),
+ },
+ ]
+ end
+
+ def download_unsigned_consent_document_status(qualification_request)
+ if qualification_request.unsigned_consent_document_downloaded
+ :completed
+ else
+ :not_started
+ end
+ end
+
+ def upload_signed_consent_document_status(qualification_request)
+ if qualification_request.unsigned_consent_document_downloaded
+ if qualification_request.signed_consent_document.completed?
+ :completed
+ else
+ :not_started
+ end
+ else
+ :cannot_start
+ end
+ end
+ end
+end
diff --git a/app/views/teacher_interface/qualification_requests/index.html.erb b/app/views/teacher_interface/qualification_requests/index.html.erb
index ceed559094..8da3ffb4dc 100644
--- a/app/views/teacher_interface/qualification_requests/index.html.erb
+++ b/app/views/teacher_interface/qualification_requests/index.html.erb
@@ -1,6 +1,8 @@
<% content_for :page_title, "Consent documents overview" %>
<% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_path) %>
-
Consent documents overview
+Consent documents overview
+
+<%= render(TaskList::Component.new(@view_object.task_list_sections)) %>
<%= govuk_button_link_to t("teacher_interface.application_forms.show.draft.save"), destroy_teacher_session_path, secondary: true %>
diff --git a/config/routes.rb b/config/routes.rb
index f3d7bea989..180c0bea5d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -347,7 +347,12 @@
resources :qualification_requests,
path: "/qualification-requests",
- only: %i[index]
+ only: %i[index] do
+ member do
+ get "download"
+ get "upload"
+ end
+ end
end
resources :reference_requests,
diff --git a/spec/lib/document_continue_redirection_spec.rb b/spec/lib/document_continue_redirection_spec.rb
index dc583aff1d..876e7bbf37 100644
--- a/spec/lib/document_continue_redirection_spec.rb
+++ b/spec/lib/document_continue_redirection_spec.rb
@@ -135,7 +135,7 @@
it do
is_expected.to eq(
- [:teacher_interface, :application_form, qualification_request],
+ %i[teacher_interface application_form qualification_requests],
)
end
end
@@ -152,7 +152,7 @@
it do
is_expected.to eq(
- [:teacher_interface, :application_form, qualification_request],
+ %i[teacher_interface application_form qualification_requests],
)
end
end
diff --git a/spec/support/autoload/page_objects/teacher_interface/qualification_requests.rb b/spec/support/autoload/page_objects/teacher_interface/qualification_requests.rb
index e1f21fc27c..53db529dbe 100644
--- a/spec/support/autoload/page_objects/teacher_interface/qualification_requests.rb
+++ b/spec/support/autoload/page_objects/teacher_interface/qualification_requests.rb
@@ -5,6 +5,8 @@ module TeacherInterface
class QualificationRequests < SitePrism::Page
set_url "/teacher/application/qualification-requests"
+ section :task_list, TaskList, ".app-task-list"
+
element :check_your_answers_button,
".govuk-button:not(.govuk-button--secondary)"
element :save_and_sign_out_button, ".govuk-button.govuk-button--secondary"
diff --git a/spec/system/teacher_interface/qualification_consent_spec.rb b/spec/system/teacher_interface/qualification_consent_spec.rb
index 5b609091c2..13ae01a714 100644
--- a/spec/system/teacher_interface/qualification_consent_spec.rb
+++ b/spec/system/teacher_interface/qualification_consent_spec.rb
@@ -25,6 +25,10 @@
when_i_visit_the(:teacher_application_page)
then_i_see_the(:teacher_application_page)
and_i_see_qualification_consent_start_now_content
+
+ when_i_click_the_start_button
+ then_i_see_the(:teacher_qualification_requests_page)
+ and_i_see_the_download_and_upload_tasks
end
def given_there_is_an_application_form
@@ -55,6 +59,14 @@ def and_i_see_qualification_consent_sign_out_content
)
end
+ def and_i_see_the_download_and_upload_tasks
+ task_list = teacher_qualification_requests_page.task_list
+ expect(task_list.sections.count).to eq(1)
+
+ task_list_section = task_list.sections.first
+ expect(task_list_section.items.count).to eq(2)
+ end
+
def teacher
@teacher ||= create(:teacher)
end
diff --git a/spec/view_objects/teacher_interface/qualification_requests_view_object_spec.rb b/spec/view_objects/teacher_interface/qualification_requests_view_object_spec.rb
new file mode 100644
index 0000000000..8b3a0e8882
--- /dev/null
+++ b/spec/view_objects/teacher_interface/qualification_requests_view_object_spec.rb
@@ -0,0 +1,143 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe TeacherInterface::QualificationRequestsViewObject do
+ subject(:view_object) { described_class.new(application_form:) }
+
+ let(:application_form) do
+ create(:application_form, :verification_stage, :with_assessment)
+ end
+
+ describe "#task_list_sections" do
+ subject(:task_list_sections) { view_object.task_list_sections }
+
+ it { is_expected.to be_empty }
+
+ context "with a qualification request" do
+ let!(:qualification_request) do
+ create(
+ :qualification_request,
+ :consent_requested,
+ assessment: application_form.assessment,
+ qualification:
+ create(
+ :qualification,
+ application_form:,
+ title: "BSc Maths",
+ institution_name: "University of Maths",
+ ),
+ )
+ end
+
+ it do
+ is_expected.to eq(
+ [
+ {
+ title: "BSc Maths (University of Maths)",
+ items: [
+ {
+ name: "Download University of Maths consent document",
+ link: [
+ :download,
+ :teacher_interface,
+ :application_form,
+ qualification_request,
+ ],
+ status: :not_started,
+ },
+ {
+ name: "Upload University of Maths consent document",
+ link: [
+ :teacher_interface,
+ :application_form,
+ qualification_request.signed_consent_document,
+ ],
+ status: :cannot_start,
+ },
+ ],
+ },
+ ],
+ )
+ end
+
+ context "when the unsigned consent document is downloaded" do
+ before do
+ qualification_request.update!(
+ unsigned_consent_document_downloaded: true,
+ )
+ end
+
+ it do
+ is_expected.to eq(
+ [
+ {
+ title: "BSc Maths (University of Maths)",
+ items: [
+ {
+ name: "Download University of Maths consent document",
+ link: [
+ :download,
+ :teacher_interface,
+ :application_form,
+ qualification_request,
+ ],
+ status: :completed,
+ },
+ {
+ name: "Upload University of Maths consent document",
+ link: [
+ :teacher_interface,
+ :application_form,
+ qualification_request.signed_consent_document,
+ ],
+ status: :not_started,
+ },
+ ],
+ },
+ ],
+ )
+ end
+
+ context "when the signed consent document is uploaded" do
+ before do
+ qualification_request.signed_consent_document.update!(
+ completed: true,
+ )
+ end
+
+ it do
+ is_expected.to eq(
+ [
+ {
+ title: "BSc Maths (University of Maths)",
+ items: [
+ {
+ name: "Download University of Maths consent document",
+ link: [
+ :download,
+ :teacher_interface,
+ :application_form,
+ qualification_request,
+ ],
+ status: :completed,
+ },
+ {
+ name: "Upload University of Maths consent document",
+ link: [
+ :teacher_interface,
+ :application_form,
+ qualification_request.signed_consent_document,
+ ],
+ status: :completed,
+ },
+ ],
+ },
+ ],
+ )
+ end
+ end
+ end
+ end
+ end
+end