From 868fdc8f5b9f26e05f93f6de0f6aec5787c67aac Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 14:03:54 +0000 Subject: [PATCH 1/8] Updated KS4 tag process --- .../KeyStage4PerformanceTables/default.cshtml | 20 +++++++-------- .../TagHelpers/KeyStageStatusRowTagHelper.cs | 4 ++- .../Utils/KeyStageDataStatusHelper.cs | 25 ++++++++++++++----- 3 files changed, 32 insertions(+), 17 deletions(-) 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/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..2697c4ec2 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 { @@ -77,16 +76,30 @@ 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(); } + 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 + } + else + { + throw new ArgumentException("Invalid input format."); + } + } public static string KeyStageHeader(int yearIndex, KeyStages keyStage) { return KeyStageHeader(yearIndex, DateTime.Now, keyStage); From 0a2654b65c3fbe49cb25132fd538cc22ab69c1ab Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 14:14:50 +0000 Subject: [PATCH 2/8] Updated as the logic sits a year behind --- .../Utils/KeyStageDataStatusHelper.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 2697c4ec2..76d072b23 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -49,9 +49,11 @@ 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 isItCurrentOrLastAcademicYear = + (date.Month < 9 && date.Year == DateTime.Now.Year) || + (date.Month < 9 && date.Year == DateTime.Now.Year - 1) || + (date.Month >= 9 && date.Year == DateTime.Now.Year - 2); + StatusType statusType = isItCurrentOrLastAcademicYear ? DetermineStatusType(date, keyStage) : StatusType.Final; return statusType.ToString(); } From c9aaa1f03673a45e0b9ae14503b817e8782c91dc Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 14:19:27 +0000 Subject: [PATCH 3/8] Updated logic to start current academic year in sept --- .../Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 76d072b23..ece66bc99 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -50,7 +50,7 @@ public static string KeyStage4DataTag(DateTime date) public static string DetermineKeyStageDataStatus(DateTime date, KeyStages keyStage) { bool isItCurrentOrLastAcademicYear = - (date.Month < 9 && date.Year == DateTime.Now.Year) || + (date.Month >= 9 && date.Year == DateTime.Now.Year) || (date.Month < 9 && date.Year == DateTime.Now.Year - 1) || (date.Month >= 9 && date.Year == DateTime.Now.Year - 2); StatusType statusType = isItCurrentOrLastAcademicYear ? DetermineStatusType(date, keyStage) : StatusType.Final; From e156f9bcc242e495551a40ec3cbe586f78200790 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 14:38:24 +0000 Subject: [PATCH 4/8] Logic updated as current year will always be current or last academic year --- .../Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index ece66bc99..2a0ed367a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -50,7 +50,7 @@ public static string KeyStage4DataTag(DateTime date) public static string DetermineKeyStageDataStatus(DateTime date, KeyStages keyStage) { bool isItCurrentOrLastAcademicYear = - (date.Month >= 9 && date.Year == DateTime.Now.Year) || + (date.Year == DateTime.Now.Year) || (date.Month < 9 && date.Year == DateTime.Now.Year - 1) || (date.Month >= 9 && date.Year == DateTime.Now.Year - 2); StatusType statusType = isItCurrentOrLastAcademicYear ? DetermineStatusType(date, keyStage) : StatusType.Final; From 300afb108863f75dda1f8fee2ccc879d9a45535e Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 15:11:50 +0000 Subject: [PATCH 5/8] Updated logic to split current and last academic years --- .../Utils/KeyStageDataStatusHelper.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 2a0ed367a..2c9ab9a6a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -49,11 +49,23 @@ public static string KeyStage4DataTag(DateTime date) public static string DetermineKeyStageDataStatus(DateTime date, KeyStages keyStage) { - bool isItCurrentOrLastAcademicYear = - (date.Year == DateTime.Now.Year) || + 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 = isItCurrentOrLastAcademicYear ? DetermineStatusType(date, keyStage) : StatusType.Final; + StatusType statusType = StatusType.Final; + if (isItCurrentAcademicYear) + { + statusType = StatusType.Provisional; + } + if (isItLastAcademicYear) + { + statusType = DetermineStatusType(date, keyStage); + } + return statusType.ToString(); } From 56c71502b0789c2dca43338632c7fa58612c7bb9 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 15:12:24 +0000 Subject: [PATCH 6/8] Further split academic performance --- .../Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 2c9ab9a6a..6a9df0e14 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -56,7 +56,9 @@ public static string DetermineKeyStageDataStatus(DateTime date, KeyStages keySta 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; From 0edb51090cbb3e911f23331f06af864d967497d4 Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Mon, 20 Nov 2023 16:42:54 +0000 Subject: [PATCH 7/8] Updated tests for educational performance --- .../TagHelpers/KeyStageDataTagHelperTests.cs | 16 ++++++++-------- .../Utils/KeyStageDataStatusHelper.cs | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) 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/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index 6a9df0e14..ae9f53b64 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -111,10 +111,8 @@ static DateTime ConvertToDateTime(string input) { return new DateTime(endYear, 8, 31); // Last day of Aug to mark end of academic year } - else - { - throw new ArgumentException("Invalid input format."); - } + // Default to current year if the year isn't in the expected value + return DateTime.UtcNow; } public static string KeyStageHeader(int yearIndex, KeyStages keyStage) { From 79d5b09f3e46bbf3fdc948468251e41db6b3063e Mon Sep 17 00:00:00 2001 From: Dominic NEED Date: Wed, 22 Nov 2023 14:59:22 +0000 Subject: [PATCH 8/8] implement fix to KS2 and KS5 --- .../Components/KeyStage2PerformanceTables/default.cshtml | 2 +- .../Components/KeyStage5PerformanceTables/default.cshtml | 2 +- .../TagHelpers/KeyStageStatusHeaderTagHelper.cs | 6 ++++-- .../Utils/KeyStageDataStatusHelper.cs | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) 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/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/Utils/KeyStageDataStatusHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs index ae9f53b64..13270f98c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Utils/KeyStageDataStatusHelper.cs @@ -114,9 +114,10 @@ static DateTime ConvertToDateTime(string input) // Default to current year if the year isn't in the expected value return DateTime.UtcNow; } - public static string KeyStageHeader(int yearIndex, KeyStages keyStage) + 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) {