Skip to content

Commit

Permalink
Change how we display Mandatory Qualifications in Check
Browse files Browse the repository at this point in the history
- Add support for rendering multiple MQs by following the same approach
  we use for NPQs
- Change the MQ section heading and make the row key more specific to
  accommodate for the fact that we may be rendering multiple MQs for
  different specialisms
- Update test data and system spec to cover these changes
  • Loading branch information
malcolmbaig committed Nov 14, 2023
1 parent 9f406a5 commit c18dae8
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/components/check_records/mq_summary_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if rows.any? %>
<div class="govuk-!-margin-bottom-9">
<h2 class="govuk-heading-m">Mandatory qualifications (MQs) for specialist teachers of pupils with sensory impairments</h2>
<%= render GovukComponent::SummaryListComponent.new(rows:) %>
</div>
<% end %>
26 changes: 26 additions & 0 deletions app/components/check_records/mq_summary_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

class CheckRecords::MqSummaryComponent < ViewComponent::Base
include ActiveModel::Model

attr_accessor :mqs

def rows
mqs.map do |mq|
{
key: {
text: key_text(mq)
},
value: {
text: mq.awarded_at.to_fs(:long_uk)
}
}
end
end

private

def key_text(mandatory_qualification)
"Date #{mandatory_qualification.details.specialism.downcase} MQ awarded"
end
end
5 changes: 4 additions & 1 deletion app/controllers/check_records/teachers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ def show
trn = SecureIdentifier.decode(params[:id])
@teacher = client.teacher(trn:)
@npqs = @teacher.qualifications.filter(&:npq?)
@other_qualifications = @teacher.qualifications.filter { |qualification| !qualification.npq? }
@mqs = @teacher.qualifications.filter(&:mq?)
@other_qualifications = @teacher.qualifications.reject do |qualification|
qualification.npq? || qualification.mq?
end
rescue QualificationsApi::TeacherNotFoundError
render "not_found"
end
Expand Down
4 changes: 4 additions & 0 deletions app/views/check_records/teachers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<%= render CheckRecords::QualificationSummaryComponent.new(qualification:) %>
<% end %>

<% if @mqs.present? %>
<%= render CheckRecords::MqSummaryComponent.new(mqs: @mqs) %>
<% end %>

<% if @npqs.present? %>
<%= render CheckRecords::NpqSummaryComponent.new(npqs: @npqs) %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion spec/support/fake_qualifications_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def quals_data(trn: nil, itt: true)
end
),
mandatoryQualifications: [
{ awarded: "2023-02-28", specialism: "Visual impairment" }
{ awarded: "2023-02-28", specialism: "Visual impairment" },
{ awarded: "2022-01-01", specialism: "Hearing" }
],
npqQualifications: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ def then_i_see_npq_details
end

def then_i_see_mq_details
expect(page).to have_content("Mandatory qualification (MQ)")
expect(page).to have_content("Date awarded\t28 February 2023")
expect(page).to have_content("Specialism\tVisual impairment")
expect(page).to have_content("Date visual impairment MQ awarded")
expect(page).to have_content("28 February 2023")
expect(page).to have_content("Date hearing MQ awarded")
expect(page).to have_content("1 January 2022")
end
end

0 comments on commit c18dae8

Please sign in to comment.