Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def update
def load_further_information_request_and_item
@further_information_request_item = further_information_request_item
@further_information_request = further_information_request
@view_object = view_object
end

def view_object
@view_object ||=
FurtherInformationRequestItemViewObject.new(current_teacher:, params:)
end

def edit_text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def show
end

def edit
render layout: "full_from_desktop"
end

def update
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# frozen_string_literal: true

module TeacherInterface
class FurtherInformationRequestItemViewObject
def initialize(current_teacher:, params:)
@current_teacher = current_teacher
@params = params
end

def further_information_request_item
@further_information_request_item ||=
FurtherInformationRequestItem
.joins(further_information_request: :assessment)
.where(
further_information_request: {
received_at: nil,
assessments: {
application_form:,
},
},
)
.find(params[:id])
end

def item_name
case further_information_request_item.information_type
when "text"
I18n.t(
further_information_request_item.failure_reason_key,
scope: %i[
teacher_interface
further_information_request
show
failure_reason
],
)
when "work_history_contact"
"Update reference details for #{further_information_request_item.work_history.school_name}"
when "document"
if further_information_request_item.document.document_type == "passport"
"Upload your #{I18n.t("document.document_type.#{further_information_request_item.document.document_type}")}"
else
"Upload your " \
"#{I18n.t("document.document_type.#{further_information_request_item.document.document_type}")} document"
end
end
end

def item_description
I18n.t(
further_information_request_item.failure_reason_key,
scope: %i[
teacher_interface
application_forms
show
declined
failure_reasons
],
).gsub(".", "")
end

def application_form
@application_form ||= current_teacher.application_form
end

private

attr_reader :current_teacher, :params
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,55 @@ def further_information_request
.find(params[:id])
end

def task_list_items
items =
further_information_request
.items
.order(:created_at)
.map do |item|
{
title: item_name(item),
href: [
:edit,
:teacher_interface,
:application_form,
further_information_request,
item,
def grouped_task_list_items
items_by_assessment_section.map do |assessment_section, items|
{
heading:
I18n.t(
assessment_section.key,
scope: %i[
teacher_interface
further_information_request
show
section
],
status: item.status,
}
end

items << {
title:
I18n.t("teacher_interface.further_information_request.show.check"),
href:
if can_check_answers?
[
:edit,
:teacher_interface,
:application_form,
further_information_request,
]
end,
status: can_check_answers? ? "not_started" : "cannot_start",
}
),
items: task_list_items(items),
}
end
end

items
def check_your_answers_task_group
{
heading:
I18n.t(
:check_your_answers,
scope: %i[
teacher_interface
further_information_request
show
section
],
),
items: [
{
title:
I18n.t(
"teacher_interface.further_information_request.show.check",
),
href:
if can_check_answers?
[
:edit,
:teacher_interface,
:application_form,
further_information_request,
]
end,
status: can_check_answers? ? "not_started" : "cannot_start",
},
],
}
end

def can_check_answers?
Expand All @@ -58,42 +72,69 @@ def can_check_answers?

alias_method :can_submit?, :can_check_answers?

def check_your_answers_fields
further_information_request
.items
.order(:created_at)
.each_with_object({}) do |item, memo|
memo[item.id] = {
def application_form
@application_form ||= current_teacher.application_form
end

private

attr_reader :current_teacher, :params

def items_by_assessment_section
@items_by_assessment_section ||=
FurtherInformationRequestItemsByAssessmentSection.call(
further_information_request:,
)
end

def task_list_items(items)
list_items =
items.map do |item|
{
title: item_name(item),
description: item_description(item),
value_title: item_value_title(item),
value: item_value(item),
assessor_note: item.failure_reason_assessor_feedback,
href: [
:edit,
:teacher_interface,
:application_form,
further_information_request,
item,
],
status: item.status,
}
end
end

def application_form
@application_form ||= current_teacher.application_form
list_items.sort_by { |item| item[:title] }
end

private

attr_reader :current_teacher, :params
def item_value_title(item)
if item.text?
"Your response"
elsif item.document?
if item.document.document_type == "passport"
I18n.t(
"document.document_type.#{item.document.document_type}",
).capitalize
else
"#{I18n.t("document.document_type.#{item.document.document_type}").capitalize} documents"
end
elsif item.work_history_contact?
"Reference details"
end
end

def item_value(item)
if item.text?
item.response
elsif item.document?
item.document
elsif item.work_history_contact?
"Contact name: #{item.contact_name}<br/>
Contact job: #{item.contact_job}<br/>
Contact email: #{item.contact_email}".html_safe
"#{item.contact_name}<br/>
#{item.contact_job}<br/>
#{item.contact_email}".html_safe
end
end

Expand All @@ -104,7 +145,7 @@ def item_name(item)
"teacher_interface.further_information_request.show.failure_reason.#{item.failure_reason_key}",
)
when "work_history_contact"
"Add work history details"
"Update reference details for #{item.work_history.school_name}"
when "document"
if item.document.document_type == "passport"
"Upload your #{I18n.t("document.document_type.#{item.document.document_type}")}"
Expand All @@ -113,5 +154,18 @@ def item_name(item)
end
end
end

def item_description(item)
I18n.t(
item.failure_reason_key,
scope: %i[
teacher_interface
application_forms
show
declined
failure_reasons
],
).gsub(".", "")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
<%= f.govuk_error_summary %>
<% end %>

<h1 class="govuk-heading-l">Further information required</h1>

<h2 class="govuk-heading-s"><%= I18n.t("teacher_interface.application_forms.show.declined.failure_reasons.#{@further_information_request_item.failure_reason_key}") %></h2>
<%
section_name = @further_information_request_item
.further_information_request
.assessment
.sections
.includes(:selected_failure_reasons)
.find_by(selected_failure_reasons: { key: @further_information_request_item.failure_reason_key })
.key
%>
<span class="govuk-caption-l"><%= I18n.t("teacher_interface.further_information_request.show.section.#{section_name}") %></span>
<% if @further_information_request_item.document? %>
<h1 class="govuk-heading-l">Review note from assessor</h1>
<% else %>
<h1 class="govuk-heading-l"><%= @view_object.item_name %></h1>
<% end %>
<h2 class="govuk-heading-s"><%= @view_object.item_description %></h2>

<%= govuk_inset_text do %>
<%= simple_format @further_information_request_item.failure_reason_assessor_feedback %>
Expand All @@ -20,9 +33,7 @@

<% if @further_information_request_item.work_history_contact? %>
<% work_history = @further_information_request_item.work_history %>
<p class="govuk-body">Enter the contact details of a suitable referee who can verify your time spent working at <%= work_history.school_name %> from <%= work_history.start_date.to_fs(:month_and_year) %> <% if work_history.end_date.present? %>
to <%= work_history.end_date.to_fs(:month_and_year) %>
<% end %></p>
<p class="govuk-body">Enter the contact details of a suitable referee who can verify your time spent working at <%= work_history.school_name %> from <%= work_history.start_date.to_fs(:month_and_year) %><% if work_history.end_date.present? %> to <%= work_history.end_date.to_fs(:month_and_year) %><% end %>.</p>

<%= f.govuk_text_field :contact_name, label: {text: "Contact’s name"} %>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
<% content_for :page_title, "Check your answers before submitting" %>
<% content_for :back_link_url, back_history_path(origin: true, default: teacher_interface_application_form_further_information_request_path(@view_object.further_information_request)) %>

<span class="govuk-caption-l">Your application</span>
<h1 class="govuk-heading-xl">Check your answers before submitting</h1>

<%= render(CheckYourAnswersSummary::Component.new(
id: "check-your-answers",
model: @view_object.further_information_request,
title: t(".check_your_answers"),
fields: @view_object.check_your_answers_fields
)) %>
<% @view_object.grouped_task_list_items.each do |grouped_task_list_item| %>
<h2 class="govuk-heading-m"><%= grouped_task_list_item[:heading] %></h2>
<% grouped_task_list_item[:items].each do |item| %>
<%= govuk_summary_card(title: item[:title] ) do |card|
card.with_summary_list do |summary_list|
summary_list.with_row do |row|
row.with_key { item[:value_title] }
row.with_value do
if item[:value].is_a?(Document)
tag.ul(class: "govuk-list") do
item[:value]
.uploads
.order(:created_at)
.each { |upload| concat(tag.li(upload_link_to(upload))) }
end
else
item[:value]
end
end
row.with_action(
href: item[:href],
visually_hidden_text: item[:title].downcase
)
end
summary_list.with_row do |row|
row.with_key { "Note from assessor" }
row.with_value do
govuk_details(summary_text: "View note", text: item[:assessor_note])
end
end
end
end %>
<% end %>
<% end %>

<% if @view_object.can_submit? %>
<h3 class="govuk-heading-m">How we handle your data</h3>
<p class="govuk-body">You can read about the data we collect from you, how we use it and how it’s stored, in our <%= govuk_link_to "privacy policy", "https://www.gov.uk/government/publications/privacy-information-education-providers-workforce-including-teachers/5a254207-a566-44f7-ac77-6ba59fd26e04#using-your-data-when-you-use-the-apply-for-qualified-teacher-status-qts-in-england-service" %>.</p>

<h3 class="govuk-heading-m">Submitting your further information</h3>
<p class="govuk-body">By selecting the ‘Submit your response’ button you confirm that, to the best of your knowledge, the details you’ve provided are correct.</p>
<p class="govuk-body">You will not be able to change your response, add new documents or delete anything once you submit it.</p>
Expand Down
Loading
Loading