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() + { + + } + } +} 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 }; } 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(); - } } }