Skip to content

Commit

Permalink
Merge pull request #980 from DFE-Digital/feature/absence-data
Browse files Browse the repository at this point in the history
Feature/absence data
  • Loading branch information
paullocknimble authored Jan 25, 2024
2 parents 4fcfcf1 + 8ac7a8c commit 83feefe
Show file tree
Hide file tree
Showing 45 changed files with 585 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="MELT" Version="0.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.8.2" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="Dfe.Academisation.CorrelationIdMiddleware" Version="2.0.2" />
<PackageReference Include="Dfe.Academisation.ExtensionMethods" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ public async Task<HttpResponseMessage> GetAllProjectsV2Async(AcademyConversionSe
{
return await AcademisationClient.PostAsync(PathFor.GetAllProjectsV2, JsonContent.Create(searchModel));
}

public async Task<HttpResponseMessage> SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel)
{
return await AcademisationClient.PutAsync(string.Format(PathFor.SetPerformanceData, id), JsonContent.Create(setPerformanceDataModel));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface IApiClient

Task<HttpResponseMessage> SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl);
Task<HttpResponseMessage> SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchoolOverview);
Task<HttpResponseMessage> SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public PathFor(IFeatureManager features)
public static string GetFilterParameters => "/legacy/projects/status";
public static string AddProjectNote => "/legacy/project/{0}/notes";
public static string SetExternalApplicationForm => "/conversion-project/{0}/setExternalApplicationForm";
public static string SetPerformanceData => "/conversion-project/{0}/SetPerformanceData";
public static string SetSchoolOverview => "/conversion-project/{0}/SetSchoolOverview";

public static string GetAllProjectsV2 => "/conversion-project/projects";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public class AcademyConversionProject
public string KeyStage2PerformanceAdditionalInformation { get; set; }
public string KeyStage4PerformanceAdditionalInformation { get; set; }
public string KeyStage5PerformanceAdditionalInformation { get; set; }
public string EducationalAttendanceAdditionalInformation { get; set; }

// assigned user
public User AssignedUser { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Dfe.Academies.Contracts.V1.EducationalPerformance;

namespace Dfe.PrepareConversions.Data.Models.KeyStagePerformance;

Expand All @@ -8,7 +9,9 @@ public class KeyStagePerformance
public IEnumerable<KeyStage2PerformanceResponse> KeyStage2 { get; set; }
public IEnumerable<KeyStage4PerformanceResponse> KeyStage4 { get; set; }
public IEnumerable<KeyStage5PerformanceResponse> KeyStage5 { get; set; }
public IEnumerable<SchoolAbsenceDataDto> SchoolAbsenceData { get; set; }

public bool HasSchoolAbsenceData => SchoolAbsenceData?.Any() ?? false;
public bool HasKeyStage2PerformanceTables => KeyStage2?.Any(HasKeyStage2Performance) ?? false;
public bool HasKeyStage4PerformanceTables => KeyStage4?.Any(HasKeyStage4Performance) ?? false;
public bool HasKeyStage5PerformanceTables => KeyStage5?.Any(HasKeyStage5Performance) ?? false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Dfe.Academies.Contracts.V1.EducationalPerformance;
using System.Collections.Generic;

namespace Dfe.PrepareConversions.Data.Models.KeyStagePerformance;

Expand All @@ -8,4 +9,5 @@ public class KeyStagePerformanceResponse
public IEnumerable<KeyStage2PerformanceResponse> KeyStage2 { get; set; }
public IEnumerable<KeyStage4PerformanceResponse> KeyStage4 { get; set; }
public IEnumerable<KeyStage5PerformanceResponse> KeyStage5 { get; set; }
public IEnumerable<SchoolAbsenceDataDto> absenceData { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dfe.PrepareConversions.Data.Models
{
public class SetPerformanceDataModel
{
public SetPerformanceDataModel(int id,
string? keyStage2PerformanceAdditionalInformation,
string? keyStage4PerformanceAdditionalInformation,
string? keyStage5PerformanceAdditionalInformation,
string? educationalAttendanceAdditionalInformation)
{
Id = id;
KeyStage2PerformanceAdditionalInformation = keyStage2PerformanceAdditionalInformation;
KeyStage4PerformanceAdditionalInformation = keyStage4PerformanceAdditionalInformation;
KeyStage5PerformanceAdditionalInformation = keyStage5PerformanceAdditionalInformation;
EducationalAttendanceAdditionalInformation = educationalAttendanceAdditionalInformation;
}

public int Id { get; set; }
public string? KeyStage2PerformanceAdditionalInformation { get; set; }
public string? KeyStage4PerformanceAdditionalInformation { get; set; }
public string? KeyStage5PerformanceAdditionalInformation { get; set; }
public string? EducationalAttendanceAdditionalInformation { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ public async Task SetProjectExternalApplicationForm(int id, bool externalApplica
HttpResponseMessage result = await _apiClient.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl);
if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}");
}

public async Task SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel)
{
HttpResponseMessage result = await _apiClient.SetPerformanceData(id, setPerformanceDataModel);
if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}");
}
public async Task SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchoolOverview)
{
HttpResponseMessage result = await _apiClient.SetSchoolOverview(id, updatedSchoolOverview);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Task<ApiResponse<ApiV2Wrapper<IEnumerable<AcademyConversionProject>>>> GetAllPro
Task CreateProject(CreateNewProject newProject);
Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl);
Task SetSchoolOverview(int id, SetSchoolOverviewModel updatedSchoolOverview);
Task SetPerformanceData(int id, SetPerformanceDataModel setPerformanceDataModel);
Task<ApiResponse<ProjectFilterParameters>> GetFilterParameters();
Task<ApiResponse<ProjectNote>> AddProjectNote(int id, AddProjectNote addProjectNote);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<KeyStagePerformance> GetKeyStagePerformance(string urn)

return new KeyStagePerformance
{
KeyStage2 = keyStagePerformanceResponse.KeyStage2, KeyStage4 = keyStagePerformanceResponse.KeyStage4, KeyStage5 = keyStagePerformanceResponse.KeyStage5
KeyStage2 = keyStagePerformanceResponse.KeyStage2, KeyStage4 = keyStagePerformanceResponse.KeyStage4, KeyStage5 = keyStagePerformanceResponse.KeyStage5, SchoolAbsenceData = keyStagePerformanceResponse.absenceData
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="Open-XML-SDK" Version="2.9.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="AngleSharp.Io" Version="1.0.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.11" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.11" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ public ProjectNote AddPostProjectNote(int id, AddProjectNote request)
return response;
}

public SetPerformanceDataModel AddPutPerformanceData(AcademyConversionProject project)
{
SetPerformanceDataModel request = _fixture
.Build<SetPerformanceDataModel>()
.OmitAutoProperties()
.With(x => x.Id, project.Id)
.With(x => x.KeyStage2PerformanceAdditionalInformation, project.KeyStage2PerformanceAdditionalInformation)
.With(x => x.KeyStage4PerformanceAdditionalInformation, project.KeyStage4PerformanceAdditionalInformation)
.With(x => x.KeyStage5PerformanceAdditionalInformation, project.KeyStage5PerformanceAdditionalInformation)
.With(x => x.EducationalAttendanceAdditionalInformation, project.EducationalAttendanceAdditionalInformation)
.Create();

_factory.AddPutWithJsonRequest(string.Format(PathFor.SetPerformanceData, project.Id), request, project);
return request;
}

public UpdateAcademyConversionProject AddPatchProjectMany(AcademyConversionProject project,
Func<IPostprocessComposer<UpdateAcademyConversionProject>, IPostprocessComposer<UpdateAcademyConversionProject>>
postProcess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public async Task Should_navigate_to_and_update_additional_information()
{
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);
UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage2PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/key-stage-2-performance-tables");
await NavigateAsync("Change", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public async Task Should_navigate_to_and_update_additional_information()
{
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);
UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage4PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/key-stage-4-performance-tables");
await NavigateAsync("Change", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public async Task Should_navigate_to_and_update_additional_information()
{
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);
UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage5PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/key-stage-5-performance-tables");
await NavigateAsync("Change", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,7 @@ public async Task Should_update_KS2_additional_information_and_navigate_back_to_
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);

UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage2PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template");

Expand Down Expand Up @@ -450,11 +446,7 @@ public async Task Should_update_KS4_additional_information_and_navigate_back_to_
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);

UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage4PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template");

Expand Down Expand Up @@ -516,11 +508,7 @@ public async Task Should_update_KS5_additional_information_and_navigate_back_to_
AcademyConversionProject project = AddGetProject();
AddGetKeyStagePerformance(project.Urn.Value);

UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x =>
{
x.KeyStage5PerformanceAdditionalInformation = _fixture.Create<string>();
x.Urn = project.Urn;
});
SetPerformanceDataModel request = AddPutPerformanceData(project);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.0.1" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.10" />
<PackageReference Include="Dfe.Academisation.CorrelationIdMiddleware" Version="2.0.2" />
<PackageReference Include="Dfe.Academisation.ExtensionMethods" Version="2.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public class HtbTemplate
public IEnumerable<KeyStage2PerformanceTableViewModel> KeyStage2 { get; set; }
public KeyStage4PerformanceTableViewModel KeyStage4 { get; set; }
public IEnumerable<KeyStage5PerformanceTableViewModel> KeyStage5 { get; set; }
public IEnumerable<EducationalAttendanceViewModel> EducationalAttendance { get; set; }

public static HtbTemplate Build(AcademyConversionProject project,
SchoolPerformance schoolPerformance,
Expand Down Expand Up @@ -337,6 +338,11 @@ public static HtbTemplate Build(AcademyConversionProject project,
htbTemplate.KeyStage5 = keyStagePerformance.KeyStage5.Select(KeyStage5PerformanceTableViewModel.Build).OrderByDescending(ks => ks.Year);
}

if (keyStagePerformance.HasSchoolAbsenceData)
{
htbTemplate.EducationalAttendance = keyStagePerformance.SchoolAbsenceData.Select(EducationalAttendanceViewModel.Build).OrderByDescending(ks => ks.Year);
}

return htbTemplate;
}
}
6 changes: 6 additions & 0 deletions Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public static class KeyStagePerformanceSection

public static readonly LinkItem KeyStage5PerformanceTablesAdditionalInformation =
AddLinkItem(page: "/TaskList/KeyStagePerformance/KeyStage5PerformanceTablesAdditionalInformation");

public static readonly LinkItem EducationalAttendance =
AddLinkItem(page: "/TaskList/KeyStagePerformance/EducationalAttendance");

public static readonly LinkItem EducationalAttendanceAdditionalInformation =
AddLinkItem(page: "/TaskList/KeyStagePerformance/EducationalAttendanceAdditionalInformation");
}

public static class Decision
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@using Dfe.PrepareConversions.Utils
@using Dfe.PrepareConversions.TagHelpers
@model IEnumerable<EducationalAttendanceViewModel>
<div>
@{
var educationalAttendanceViewModels = Model.OrderByDescending(x => x.Year).ToList();
}

<table class="govuk-table govuk-!-margin-bottom-9">
<caption class="govuk-table__caption govuk-table__caption--m">
<h1 class="govuk-heading-m">Overall absence</h1>
<p class="govuk-!-margin-top govuk-body">Percentage of mornings or afternoons recorded as an absence from school for any reason, across the full academic year.</p>
</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header"></th>

@for (int i = 0; i < 3; i++)
{
var vm = educationalAttendanceViewModels[i];

<th scope="col" class="govuk-table__header">@vm.Year</th>
}

</tr>
</thead>
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">@ViewData["SchoolName"]</th>
@for (int i = 0; i < 3; i++)
{
var vm = educationalAttendanceViewModels[i];
<td class="govuk-table__cell" id="@("percentage-overall-" + i)">@vm.OverallAbsence</td>
}
</tr>
</tbody>
</table>

<table class="govuk-table govuk-!-margin-bottom-9">
<caption class="govuk-table__caption govuk-table__caption--m">
<h1 class="govuk-heading-m">Persistent absence of 10% or more</h1>
<p class="govuk-!-margin-top govuk-body">The percentage of pupils missing 10% or more of the mornings or afternoons they could attend.</p>
</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header"></th>
@for (int i = 0; i < 3; i++)
{
var vm = educationalAttendanceViewModels[i];

<th scope="col" class="govuk-table__header">@vm.Year</th>
}

</tr>
</thead>
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">@ViewData["SchoolName"]</th>
@for (int i = 0; i < 3; i++)
{
var vm = educationalAttendanceViewModels[i];
<td class="govuk-table__cell" id="@("percentage-overall-above-10" + i)">@vm.PersistentAbsence</td>
}
</tr>
</tbody>
</table>
</div>
Loading

0 comments on commit 83feefe

Please sign in to comment.