From 6d327fe8fae893e232ed31ad73e956d39b1b29d4 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 12 Oct 2021 12:02:15 +0100 Subject: [PATCH 1/3] DLSV2-368 Removes unused service requests to return individual strings --- .../Services/SelfAssessmentService.cs | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/DigitalLearningSolutions.Data/Services/SelfAssessmentService.cs b/DigitalLearningSolutions.Data/Services/SelfAssessmentService.cs index 8c72f4ef44..d0191347a1 100644 --- a/DigitalLearningSolutions.Data/Services/SelfAssessmentService.cs +++ b/DigitalLearningSolutions.Data/Services/SelfAssessmentService.cs @@ -36,8 +36,6 @@ public interface ISelfAssessmentService IEnumerable GetValidSupervisorsForActivity(int centreId, int selfAssessmentId); Administrator GetSupervisorByAdminId(int supervisorAdminId); IEnumerable? GetSupervisorSignOffsForCandidateAssessment(int selfAssessmentId, int candidateId); - string GetSignOffSupervisorRoleForSelfAssessment(int selfAssessmentId); - string GetVerificationSupervisorRoleForSelfAssessment(int selfAssessmentId); //UPDATE void UpdateLastAccessed(int selfAssessmentId, int candidateId); void SetSubmittedDateNow(int selfAssessmentId, int candidateId); @@ -853,23 +851,5 @@ public void UpdateCandidateAssessmentSupervisorVerificationEmailSent(int candida new { candidateAssessmentSupervisorVerificationId } ); } - - public string GetSignOffSupervisorRoleForSelfAssessment(int selfAssessmentId) - { - return connection.Query( - @"SELECT COALESCE - ((SELECT TOP (1) RoleName - FROM SelfAssessmentSupervisorRoles - WHERE (SelfAssessmentReview = 1) AND (SelfAssessmentID = @selfAssessmentId)), 'Supervisor') AS SignOffRoleName", new { selfAssessmentId }).FirstOrDefault(); - } - - public string GetVerificationSupervisorRoleForSelfAssessment(int selfAssessmentId) - { - return connection.Query( - @"SELECT COALESCE - ((SELECT TOP (1) RoleName - FROM SelfAssessmentSupervisorRoles - WHERE (ResultsReview = 1) AND (SelfAssessmentID = @selfAssessmentId) AND (SELECT COUNT(*) FROM SelfAssessmentSupervisorRoles WHERE (ResultsReview = 1) AND (SelfAssessmentID = @selfAssessmentId)) = 1), 'Supervisor') AS SignOffRoleName", new { selfAssessmentId }).FirstOrDefault(); - } } } From bfb682eda32c2efaed207c2bb5c59f9ec4b2d48a Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 12 Oct 2021 15:48:04 +0100 Subject: [PATCH 2/3] DLSV2-368 Updates tests to include new fields in expected result --- .../TestHelpers/SelfAssessmentHelper.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DigitalLearningSolutions.Data.Tests/TestHelpers/SelfAssessmentHelper.cs b/DigitalLearningSolutions.Data.Tests/TestHelpers/SelfAssessmentHelper.cs index 6e5957e8ad..47090d06d3 100644 --- a/DigitalLearningSolutions.Data.Tests/TestHelpers/SelfAssessmentHelper.cs +++ b/DigitalLearningSolutions.Data.Tests/TestHelpers/SelfAssessmentHelper.cs @@ -19,7 +19,9 @@ public static CurrentSelfAssessment CreateDefaultSelfAssessment( bool unprocessedUpdates = false, bool linearNavigation = true, bool useDescriptionExpanders = true, - string vocabulary = "Capability" + string vocabulary = "Capability", + string verificationRoleName = "Supervisor", + string signOffRoleName = "Supervisor" ) { return new CurrentSelfAssessment() @@ -35,7 +37,9 @@ public static CurrentSelfAssessment CreateDefaultSelfAssessment( UnprocessedUpdates = unprocessedUpdates, LinearNavigation = linearNavigation, UseDescriptionExpanders = useDescriptionExpanders, - Vocabulary = vocabulary + Vocabulary = vocabulary, + VerificationRoleName = verificationRoleName, + SignOffRoleName = signOffRoleName }; } From a8f6b29be0b982386eb3b45d628cb4e36bb14cd5 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 12 Oct 2021 16:10:51 +0100 Subject: [PATCH 3/3] DLSV2-369 Migration to update SelfAssessmentStructure ordering where necessary --- ...1_UpdateSelfAssessmentStructureOrdering.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 DigitalLearningSolutions.Data.Migrations/202110121601_UpdateSelfAssessmentStructureOrdering.cs diff --git a/DigitalLearningSolutions.Data.Migrations/202110121601_UpdateSelfAssessmentStructureOrdering.cs b/DigitalLearningSolutions.Data.Migrations/202110121601_UpdateSelfAssessmentStructureOrdering.cs new file mode 100644 index 0000000000..4068f01b92 --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202110121601_UpdateSelfAssessmentStructureOrdering.cs @@ -0,0 +1,22 @@ +namespace DigitalLearningSolutions.Data.Migrations +{ + using FluentMigrator; + [Migration(202110121601)] + public class UpdateSelfAssessmentStructureOrdering : Migration + { + public override void Up() + { + Execute.Sql(@"WITH T AS (SELECT ID, SelfAssessmentID, CompetencyID, Ordering, ROW_NUMBER() OVER(Partition By SelfAssessmentID Order By ID) As NewOrdering + FROM SelfAssessmentStructure + WHERE Ordering = 1) + UPDATE SelfAssessmentStructure + SET Ordering = T.NewOrdering + FROM SelfAssessmentStructure AS sas INNER JOIN T ON T.ID = sas.ID + WHERE T.NewOrdering > 1"); + } + public override void Down() + { + + } + } +}