diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs index 640d2aa55..ff7cdbb38 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/TagHelpers/KeyStageDataTagHelperTests.cs @@ -15,10 +15,10 @@ public KeyStageDataTagHelperTests(IntegrationTestingWebApplicationFactory factor [Theory] [InlineData(0, StatusType.Provisional, "YearIndex 0 would be the current year, thus, status is provisional based on the currentDate variables month")] - [InlineData(1, StatusType.Final, "YearIndex 1 would be a year ago, thus, status is Final")] + [InlineData(1, StatusType.Provisional, "YearIndex 1 would be a year ago, thus, status is Final")] [InlineData(2, StatusType.Final, "YearIndex 2 would be two years ago, thus, status is Final")] [InlineData(3, StatusType.Final, "Edge case: If greater than our expected (Likely due to extending the number of years served in the future)")] - [InlineData(-1, StatusType.Final, "Edge case: Default to Final")] + [InlineData(-1, StatusType.Final, "Edge case: Default to Final")] public void KeyStageHeader_ReturnsExpectedStatusHeader(int yearIndex, StatusType expectedStatusType, string reason) { // Arrange @@ -94,17 +94,17 @@ public static IEnumerable ProvisionalDates() public static IEnumerable RevisedDates() { - yield return new object[] { new DateTime(DateTime.Now.Year, 1, 3) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 2, 11) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 3, 21) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 4, 14) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 1, 3) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 2, 11) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 3, 21) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 4, 14) }; } public static IEnumerable FinalDates() { yield return new object[] { new DateTime(DateTime.Now.Year - 2, 1, 3) }; yield return new object[] { new DateTime(DateTime.Now.Year - 2, 2, 11) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 5, 21) }; - yield return new object[] { new DateTime(DateTime.Now.Year, 6, 14) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 5, 21) }; + yield return new object[] { new DateTime(DateTime.Now.Year - 1, 6, 14) }; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage2PerformanceTables/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage2PerformanceTables/default.cshtml index 8ea7e0b59..d5e4ee430 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage2PerformanceTables/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage2PerformanceTables/default.cshtml @@ -10,7 +10,7 @@ @vm.Year key stage 2 - + Percentage meeting expected standard in reading, writing and maths Percentage achieving a higher standard in reading, writing and maths Reading progress scores diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage4PerformanceTables/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage4PerformanceTables/default.cshtml index eb767ced5..6b7ab46a7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage4PerformanceTables/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage4PerformanceTables/default.cshtml @@ -17,7 +17,7 @@ - + @* disadvantaged *@ @@ -51,7 +51,7 @@ - + @ViewData["SchoolName"] @@ -85,7 +85,7 @@ - + @ViewData["SchoolName"] @@ -119,7 +119,7 @@ - + @ViewData["SchoolName"] @@ -157,7 +157,7 @@ - + @ViewData["SchoolName"] @@ -190,7 +190,7 @@ - + @ViewData["SchoolName"] @Model.Progress8Score @@ -241,7 +241,7 @@ - + @ViewData["SchoolName"] @Model.Progress8ScoreEnglish @@ -274,7 +274,7 @@ - + @ViewData["SchoolName"] @Model.Progress8ScoreMaths @@ -307,7 +307,7 @@ - + @ViewData["SchoolName"] @Model.Progress8ScoreEbacc @@ -342,7 +342,7 @@ - + @ViewData["SchoolName"] @Model.PercentageEnteringEbacc diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage5PerformanceTables/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage5PerformanceTables/default.cshtml index 68cb3f390..aed3a39e2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage5PerformanceTables/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/KeyStage5PerformanceTables/default.cshtml @@ -14,7 +14,7 @@ Local authority: @ViewData["LocalAuthority"] - + Academic progress Academic average Applied general progress diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusHeaderTagHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusHeaderTagHelper.cs index 40becee3e..fe06ec841 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusHeaderTagHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusHeaderTagHelper.cs @@ -11,11 +11,13 @@ public class KeyStageHeaderTagHelper : TagHelper [HtmlAttributeName("key-stage")] public KeyStageDataStatusHelper.KeyStages KeyStage { get; set; } + [HtmlAttributeName("latest-year")] + public string LatestYear { get; set; } public override void Process(TagHelperContext context, TagHelperOutput output) { - output.TagName = null; - string headerContent = KeyStageDataStatusHelper.KeyStageHeader(YearIndex, KeyStage); + output.TagName = null; + string headerContent = KeyStageDataStatusHelper.KeyStageHeader(YearIndex, KeyStage, LatestYear); output.Content.AppendHtml(headerContent); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusRowTagHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusRowTagHelper.cs index 11ff055bc..8b0d2bd2c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusRowTagHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/KeyStageStatusRowTagHelper.cs @@ -8,11 +8,13 @@ public class KeyStageDataRowTagHelper : TagHelper { [HtmlAttributeName("key-stage")] public KeyStageDataStatusHelper.KeyStages KeyStage { get; set; } + [HtmlAttributeName("latest-year")] + public string LatestYear { get; set; } public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = null; - string rowContent = KeyStageDataStatusHelper.KeyStage4DataRow(); + string rowContent = KeyStageDataStatusHelper.KeyStage4DataRow(LatestYear); output.Content.SetHtmlContent(rowContent); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index dda1d4828..13270f98c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -1,5 +1,4 @@ using Dfe.PrepareConversions.DocumentGeneration.Elements; -using Microsoft.AspNetCore.Razor.TagHelpers; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -7,7 +6,7 @@ namespace Dfe.PrepareConversions.Utils; -public class KeyStageDataStatusHelper +public class KeyStageDataStatusHelper { public enum StatusType { @@ -50,9 +49,25 @@ public static string KeyStage4DataTag(DateTime date) public static string DetermineKeyStageDataStatus(DateTime date, KeyStages keyStage) { - bool isItCurrentAcademicYear = (date.Month < 9 && date.Year == DateTime.Now.Year) || - (date.Month >= 9 && date.Year == DateTime.Now.Year - 1); - StatusType statusType = isItCurrentAcademicYear ? DetermineStatusType(date, keyStage) : StatusType.Final; + bool isItCurrentAcademicYear = + (date.Month < 9 && date.Year == DateTime.Now.Year) || + (date.Month >= 9 && date.Year == DateTime.Now.Year - 1); + + bool isItLastAcademicYear = + (date.Month < 9 && date.Year == DateTime.Now.Year - 1) || + (date.Month >= 9 && date.Year == DateTime.Now.Year - 2); + + StatusType statusType = StatusType.Final; + + if (isItCurrentAcademicYear) + { + statusType = StatusType.Provisional; + } + if (isItLastAcademicYear) + { + statusType = DetermineStatusType(date, keyStage); + } + return statusType.ToString(); } @@ -77,19 +92,32 @@ private static StatusType DetermineStatusType(DateTime date, KeyStages keyStage) } - public static string KeyStage4DataRow() + public static string KeyStage4DataRow(string latestYear) { + DateTime latestYearWeHaveDataFor = ConvertToDateTime(latestYear); StringBuilder rowString = new(""); rowString.Append("Status"); - rowString.Append(KeyStage4DataTag(DateTime.Now)); - rowString.Append(KeyStage4DataTag(DateTime.Now.AddYears(-1))); - rowString.Append(KeyStage4DataTag(DateTime.Now.AddYears(-2))); + rowString.Append(KeyStage4DataTag(latestYearWeHaveDataFor)); + rowString.Append(KeyStage4DataTag(latestYearWeHaveDataFor.AddYears(-1))); + rowString.Append(KeyStage4DataTag(latestYearWeHaveDataFor.AddYears(-2))); rowString.Append(""); return rowString.ToString(); } - public static string KeyStageHeader(int yearIndex, KeyStages keyStage) + static DateTime ConvertToDateTime(string input) + { + string[] parts = input.Split(new string[] { " to " }, StringSplitOptions.None); + + if (parts.Length == 2 && int.TryParse(parts[1], out int endYear)) + { + return new DateTime(endYear, 8, 31); // Last day of Aug to mark end of academic year + } + // Default to current year if the year isn't in the expected value + return DateTime.UtcNow; + } + public static string KeyStageHeader(int yearIndex, KeyStages keyStage, string latestYear) { - return KeyStageHeader(yearIndex, DateTime.Now, keyStage); + DateTime latestYearWeHaveDataFor = ConvertToDateTime(latestYear); + return KeyStageHeader(yearIndex, latestYearWeHaveDataFor, keyStage); } public static string KeyStageHeader(int yearIndex, DateTime currentDate, KeyStages keyStage) {