diff --git a/DigitalLearningSolutions.Data.Migrations/202507240953_Alter_GetActivitiesForDelegateEnrolment_Retired_SA.cs b/DigitalLearningSolutions.Data.Migrations/202507240953_Alter_GetActivitiesForDelegateEnrolment_Retired_SA.cs new file mode 100644 index 0000000000..abf874dd9b --- /dev/null +++ b/DigitalLearningSolutions.Data.Migrations/202507240953_Alter_GetActivitiesForDelegateEnrolment_Retired_SA.cs @@ -0,0 +1,18 @@ +using FluentMigrator; + +namespace DigitalLearningSolutions.Data.Migrations +{ + [Migration(202507240953)] + public class Alter_GetActivitiesForDelegateEnrolment_Retired_SA : Migration + { + public override void Up() + { + Execute.Sql(Properties.Resources.TD_5535_Alter_GetActivitiesForDelegateEnrolment_Up); + } + public override void Down() + { + Execute.Sql(Properties.Resources.TD_5535_Alter_GetActivitiesForDelegateEnrolment_Down); + } + } +} + diff --git a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs index 0f99da6fea..631af7bc66 100644 --- a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs +++ b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs @@ -478,8 +478,7 @@ internal static string DLSV2_272_AlterGetLinkedFieldNameFunction_UP { ///-- Create date: 15/10/2021 ///-- Description: Reorders the CompetencyAssessmentQuestions - moving the given competency question up or down. ///-- ============================================= - ///CREATE OR ALTER PROCEDURE [dbo].[ReorderCompetencyAssessmentQuestion] - /// [rest of string was truncated]";. + ///CREATE OR ALTER PROCEDURE [dbo].[ReorderCompetencyAssessmentQuestion] /// [rest of string was truncated]";. /// internal static string DLSV2_379_ReorderCompetencyAssessmentQuestionsSP { get { @@ -1505,8 +1504,7 @@ internal static string TD_3190_SendOneMonthSelfAssessmentOverdueRemindersSP { /// @EmailProfileName nvarchar(100), /// @TestOnly bit ///AS - ///BEGIN - /// [rest of string was truncated]";. + ///BEGIN /// [rest of string was truncated]";. /// internal static string TD_3190_SendOneMonthSelfAssessmentTBCRemindersSP { get { @@ -2526,17 +2524,78 @@ internal static string TD_5514_Alter_SendExpiredTBCReminders_Up { } } + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 24/07/2025 02:06:43 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 24/01/2023 + ///-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category. + ///-- ========= [rest of string was truncated]";. + /// + internal static string TD_5535_Alter_GetActivitiesForDelegateEnrolment_Down { + get { + return ResourceManager.GetString("TD_5535_Alter_GetActivitiesForDelegateEnrolment_Down", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to /****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 24/07/2025 02:06:43 ******/ + ///SET ANSI_NULLS ON + ///GO + /// + ///SET QUOTED_IDENTIFIER ON + ///GO + /// + ///-- ============================================= + ///-- Author: Kevin Whittaker + ///-- Create date: 24/01/2023 + ///-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category. + ///-- ========= [rest of string was truncated]";. + /// + internal static string TD_5535_Alter_GetActivitiesForDelegateEnrolment_Up { + get { + return ResourceManager.GetString("TD_5535_Alter_GetActivitiesForDelegateEnrolment_Up", resourceCulture); + } + } + /// /// Looks up a localized string similar to IF OBJECT_ID('dbo.IndexOptimize', 'P') IS NOT NULL DROP PROCEDURE dbo.IndexOptimize; ///IF OBJECT_ID('dbo.CommandExecute', 'P') IS NOT NULL DROP PROCEDURE dbo.CommandExecute; + ///IF OBJECT_ID('dbo.sp_purge_commandlog', 'P') IS NOT NULL DROP PROCEDURE dbo.sp_purge_commandlog; ///IF OBJECT_ID('dbo.CommandLog', 'U') IS NOT NULL DROP TABLE dbo.CommandLog; ///. /// internal static string TD_5670_MaintenanceScripts_DOWN { get { return ResourceManager.GetString("TD-5670-MaintenanceScripts_DOWN", resourceCulture); - } + } } + + /// + /// Looks up a localized string similar to -- ============================================ + ///-- Drop if exists (for clean redeploy) + ///-- ============================================ + ///IF OBJECT_ID('dbo.IndexOptimize', 'P') IS NOT NULL DROP PROCEDURE dbo.IndexOptimize; + ///IF OBJECT_ID('dbo.DatabaseIntegrityCheck', 'P') IS NOT NULL DROP PROCEDURE dbo.DatabaseIntegrityCheck; + ///IF OBJECT_ID('dbo.CommandExecute', 'P') IS NOT NULL DROP PROCEDURE dbo.CommandExecute; + ///IF OBJECT_ID('dbo.CommandLog', 'U') IS NOT NULL DROP TABLE dbo.CommandLog; + ///GO + /// + ///-- =========== [rest of string was truncated]";. + /// + internal static string TD_5670_MaintenanceScripts_UP { + get { + return ResourceManager.GetString("TD_5670_MaintenanceScripts_UP", resourceCulture); + } + } + + /// /// Looks up a localized string similar to CREATE OR ALTER PROCEDURE [dbo].[usp_GetSelfAssessmentReport] /// @SelfAssessmentID INT, /// @CentreID INT @@ -2561,27 +2620,6 @@ internal static string TD_5759_CreateOrAlterSelfAssessmentReportSPandTVF_Fix_UP } /// - /// Looks up a localized string similar to -- ============================================ - ///-- CommandLog table - ///-- ============================================ - ///IF OBJECT_ID('dbo.CommandLog', 'U') IS NOT NULL DROP TABLE dbo.CommandLog; - ///CREATE TABLE dbo.CommandLog ( - /// ID INT IDENTITY PRIMARY KEY, - /// DatabaseName SYSNAME NULL, - /// SchemaName SYSNAME NULL, - /// ObjectName SYSNAME NULL, - /// ObjectType CHAR(2) NULL, - /// IndexName SYSNAME NULL, - /// IndexType TINYINT NULL, - /// StatisticsName SYSNAME NULL, - /// PartitionNumber INT NULL, - /// Ext [rest of string was truncated]";. - /// - internal static string TD_5670_MaintenanceScripts_UP { - get { - return ResourceManager.GetString("TD_5670_MaintenanceScripts_UP", resourceCulture); - } - } /// Looks up a localized string similar to CREATE OR ALTER FUNCTION dbo.GetOtherCentresForSelfAssessmentTVF ///( /// @UserID INT, diff --git a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx index 55d97e6ce3..41e1de40a2 100644 --- a/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx +++ b/DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx @@ -499,4 +499,10 @@ ..\Scripts\TD-5759_CreateOrAlterSelfAssessmentReportSPandTVF-Fix_UP.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + ..\Scripts\TD-5535-Alter_GetActivitiesForDelegateEnrolment_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + + + ..\Scripts\TD-5535-Alter_GetActivitiesForDelegateEnrolment_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + \ No newline at end of file diff --git a/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Down.sql b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Down.sql new file mode 100644 index 0000000000..d2f8374a09 Binary files /dev/null and b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Down.sql differ diff --git a/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Up.sql b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Up.sql new file mode 100644 index 0000000000..0e8c76138f Binary files /dev/null and b/DigitalLearningSolutions.Data.Migrations/Scripts/TD-5535-Alter_GetActivitiesForDelegateEnrolment_Up.sql differ diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs index bb1dc7649f..1522d93b0d 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs @@ -12,28 +12,31 @@ public IEnumerable GetSelfAssessmentsForCandidate(int del { return connection.Query( @"SELECT SelfAssessment.Id, - SelfAssessment.Name, - SelfAssessment.Description, - SelfAssessment.IncludesSignposting, - SelfAssessment.IncludeRequirementsFilters, - SelfAssessment. IsSupervisorResultsReviewed, - SelfAssessment.ReviewerCommentsLabel, - SelfAssessment. Vocabulary, - SelfAssessment. NumberOfCompetencies, - SelfAssessment.StartedDate, - SelfAssessment.LastAccessed, - SelfAssessment.CompleteByDate, - SelfAssessment.CandidateAssessmentId, - SelfAssessment.UserBookmark, - SelfAssessment.UnprocessedUpdates, - SelfAssessment.LaunchCount, - SelfAssessment. IsSelfAssessment, - SelfAssessment.SubmittedDate, - SelfAssessment. CentreName, - SelfAssessment.EnrolmentMethodId, - Signoff.SignedOff, - Signoff.Verified, - EnrolledByForename +' '+EnrolledBySurname AS EnrolledByFullName + SelfAssessment.Name, + SelfAssessment.Description, + SelfAssessment.IncludesSignposting, + SelfAssessment.IncludeRequirementsFilters, + SelfAssessment. IsSupervisorResultsReviewed, + SelfAssessment.ReviewerCommentsLabel, + SelfAssessment. Vocabulary, + SelfAssessment. NumberOfCompetencies, + SelfAssessment.StartedDate, + SelfAssessment.LastAccessed, + SelfAssessment.CompleteByDate, + SelfAssessment.CandidateAssessmentId, + SelfAssessment.UserBookmark, + SelfAssessment.UnprocessedUpdates, + SelfAssessment.LaunchCount, + SelfAssessment. IsSelfAssessment, + SelfAssessment.SubmittedDate, + SelfAssessment. CentreName, + SelfAssessment.EnrolmentMethodId, + SelfAssessment.RetirementDate, + SelfAssessment.EnrolmentCutoffDate, + SelfAssessment.RetirementReason, + Signoff.SignedOff, + Signoff.Verified, + EnrolledByForename +' '+EnrolledBySurname AS EnrolledByFullName FROM (SELECT CA.SelfAssessmentID AS Id, SA.Name, @@ -56,7 +59,10 @@ public IEnumerable GetSelfAssessmentsForCandidate(int del CR.CentreName AS CentreName, CA.EnrolmentMethodId, uEnrolledBy.FirstName AS EnrolledByForename, - uEnrolledBy.LastName AS EnrolledBySurname + uEnrolledBy.LastName AS EnrolledBySurname, + SA.RetirementDate, + SA.EnrolmentCutoffDate, + SA.RetirementReason FROM Centres AS CR INNER JOIN CandidateAssessments AS CA INNER JOIN SelfAssessments AS SA ON CA.SelfAssessmentID = SA.ID ON CR.CentreID = CA.CentreID INNER JOIN @@ -71,7 +77,7 @@ Competencies AS C RIGHT OUTER JOIN AND (ISNULL(@adminIdCategoryID, 0) = 0 OR sa.CategoryID = @adminIdCategoryId) GROUP BY CA.SelfAssessmentID, SA.Name, SA.Description, SA.IncludesSignposting, SA.SupervisorResultsReview, - SA.ReviewerCommentsLabel, SA.IncludeRequirementsFilters, + SA.ReviewerCommentsLabel, SA.IncludeRequirementsFilters, SA.RetirementDate,SA.EnrolmentCutoffDate,SA.RetirementReason, COALESCE(SA.Vocabulary, 'Capability'), CA.StartedDate, CA.LastAccessed, CA.CompleteByDate, CA.ID, CA.UserBookmark, CA.UnprocessedUpdates, CA.LaunchCount, CA.SubmittedDate, CR.CentreName,CA.EnrolmentMethodId, diff --git a/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessment.cs b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessment.cs index 1beabfb672..20c401b52f 100644 --- a/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessment.cs +++ b/DigitalLearningSolutions.Data/Models/SelfAssessments/SelfAssessment.cs @@ -1,4 +1,6 @@ -namespace DigitalLearningSolutions.Data.Models.SelfAssessments +using System; + +namespace DigitalLearningSolutions.Data.Models.SelfAssessments { public class SelfAssessment : CurrentLearningItem { @@ -11,6 +13,9 @@ public class SelfAssessment : CurrentLearningItem public string? ManageOptionalCompetenciesPrompt { get; set; } public string? QuestionLabel { get; set; } public string? DescriptionLabel { get; set; } + public DateTime? RetirementDate { get; set; } + public DateTime? EnrolmentCutoffDate { get; set; } + public string? RetirementReason { get; set; } } } diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs index ed30c74566..ad15189eb1 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs @@ -44,7 +44,9 @@ public async Task Current( var centreId = User.GetCentreIdKnownNotNull(); var selfAssessments = - selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0); + selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0) + .Where(r => (r.RetirementDate != null && r.RetirementDate.Value.Date >= DateTime.UtcNow.Date) + || r.RetirementDate == null).ToList(); var (learningResources, apiIsAccessible) = await GetIncompleteActionPlanResourcesIfSignpostingEnabled(delegateUserId);