Skip to content

Commit 4f7265a

Browse files
authored
Merge pull request #2642 from TechnologyEnhancedLearning/Develop/Fixes/TD-3671-Fewcourseswhichdoesnotallowselfenrolment
TD-3671 Fixed enrolling from 'Tracking system-Manage Delegate' view doesn't appear on 'Current activities'
2 parents 8ad6736 + ef7d2ef commit 4f7265a

7 files changed

+356
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202405161044)]
6+
public class AlterGetCurrentCoursesForCandidate_V2 : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc1_up );
11+
Execute.Sql(Properties.Resources.TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up );
12+
}
13+
public override void Down()
14+
{
15+
Execute.Sql(Properties.Resources.TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc_down);
16+
Execute.Sql(Properties.Resources.TD_3671_Alter_CheckDelegateStatusForCustomisation_func_down);
17+
}
18+
}
19+
}

DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,16 @@
376376
<data name="TD_4015_Update_GetCompletedCoursesForCandidate_proc_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
377377
<value>..\Scripts\TD-4015-GetCompletedCoursesForCandidateFix_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
378378
</data>
379-
</root>
379+
<data name="TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
380+
<value>..\Resources\TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
381+
</data>
382+
<data name="TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc1_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
383+
<value>..\Resources\TD-3671-Alter_GetCurrentCoursesForCandidate_V2_proc1_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
384+
</data>
385+
<data name="TD_3671_Alter_CheckDelegateStatusForCustomisation_func_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
386+
<value>..\Resources\TD_3671_Alter_CheckDelegateStatusForCustomisation_func_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
387+
</data>
388+
<data name="TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
389+
<value>..\Resources\TD-3671-Alter_GetCurrentCoursesForCandidate_V2_proc_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
390+
</data>
391+
</root>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
/****** Object: StoredProcedure [dbo].[GetCurrentCoursesForCandidate_V2] Script Date: 08/05/2024 10:34:29 ******/
3+
SET ANSI_NULLS ON
4+
GO
5+
SET QUOTED_IDENTIFIER ON
6+
GO
7+
-- =============================================
8+
-- Author: Kevin Whittaker
9+
-- Create date: 16/12/2016
10+
-- Description: Returns a list of active progress records for the candidate.
11+
-- Change 18/09/2018: Adds logic to exclude Removed courses from returned results.
12+
-- =============================================
13+
ALTER PROCEDURE [dbo].[GetCurrentCoursesForCandidate_V2]
14+
-- Add the parameters for the stored procedure here
15+
@CandidateID int
16+
AS
17+
BEGIN
18+
-- SET NOCOUNT ON added to prevent extra result sets from
19+
-- interfering with SELECT statements.
20+
SET NOCOUNT ON;
21+
22+
-- Insert statements for procedure here
23+
SELECT p.ProgressID, (CASE WHEN cu.CustomisationName <> '' THEN a.ApplicationName + ' - ' + cu.CustomisationName ELSE a.ApplicationName END) AS CourseName, p.CustomisationID, p.SubmittedTime AS LastAccessed,
24+
p.FirstSubmittedTime AS StartedDate, p.DiagnosticScore, p.PLLocked, cu.IsAssessed, dbo.CheckCustomisationSectionHasDiagnostic(p.CustomisationID, 0)
25+
AS HasDiagnostic, dbo.CheckCustomisationSectionHasLearning(p.CustomisationID, 0) AS HasLearning,
26+
COALESCE
27+
((SELECT COUNT(Passes) AS Passes
28+
FROM (SELECT COUNT(AssessAttemptID) AS Passes
29+
FROM AssessAttempts AS aa
30+
WHERE (CandidateID = p.CandidateID) AND (CustomisationID = p.CustomisationID) AND (Status = 1)
31+
GROUP BY SectionNumber) AS derivedtbl_2), 0) AS Passes,
32+
(SELECT COUNT(SectionID) AS Sections
33+
FROM Sections AS s
34+
WHERE (ApplicationID = cu.ApplicationID)) AS Sections, p.CompleteByDate, CAST(CASE WHEN p.CompleteByDate IS NULL THEN 0 WHEN p.CompleteByDate < getDate()
35+
THEN 2 WHEN p.CompleteByDate < DATEADD(M, + 1, getDate()) THEN 1 ELSE 0 END AS INT) AS OverDue, p.EnrollmentMethodID, dbo.GetCohortGroupCustomisationID(p.ProgressID) AS GroupCustomisationID, p.SupervisorAdminID
36+
37+
FROM Progress AS p INNER JOIN
38+
Customisations AS cu ON p.CustomisationID = cu.CustomisationID INNER JOIN
39+
Applications AS a ON cu.ApplicationID = a.ApplicationID
40+
WHERE (p.Completed IS NULL) AND (p.RemovedDate IS NULL) AND (p.CandidateID = @CandidateID)AND (cu.CustomisationName <> 'ESR') AND (a.ArchivedDate IS NULL) AND (cu.Active = 1) AND ((p.SubmittedTime > DATEADD(M, -6, getDate()) OR (EnrollmentMethodID <> 1)) OR NOT p.CompleteByDate IS NULL)
41+
ORDER BY p.SubmittedTime Desc
42+
END
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/****** Object: StoredProcedure [dbo].[GetCurrentCoursesForCandidate_V2] Script Date: 16/05/2024 09:37:05 ******/
2+
SET ANSI_NULLS ON
3+
GO
4+
5+
SET QUOTED_IDENTIFIER ON
6+
GO
7+
8+
-- =============================================
9+
-- Author: Kevin Whittaker
10+
-- Create date: 16/12/2016
11+
-- Description: Returns a list of active progress records for the candidate.
12+
-- Change 18/09/2018: Adds logic to exclude Removed courses from returned results.
13+
-- =============================================
14+
ALTER PROCEDURE [dbo].[GetCurrentCoursesForCandidate_V2]
15+
-- Add the parameters for the stored procedure here
16+
@CandidateID int
17+
AS
18+
BEGIN
19+
-- SET NOCOUNT ON added to prevent extra result sets from
20+
-- interfering with SELECT statements.
21+
SET NOCOUNT ON;
22+
23+
-- Insert statements for procedure here
24+
SELECT p.ProgressID, (CASE WHEN cu.CustomisationName <> '' THEN a.ApplicationName + ' - ' + cu.CustomisationName ELSE a.ApplicationName END) AS CourseName, p.CustomisationID, p.SubmittedTime AS LastAccessed,
25+
p.FirstSubmittedTime AS StartedDate, p.DiagnosticScore, p.PLLocked, cu.IsAssessed, dbo.CheckCustomisationSectionHasDiagnostic(p.CustomisationID, 0)
26+
AS HasDiagnostic, dbo.CheckCustomisationSectionHasLearning(p.CustomisationID, 0) AS HasLearning,
27+
COALESCE
28+
((SELECT COUNT(Passes) AS Passes
29+
FROM (SELECT COUNT(AssessAttemptID) AS Passes
30+
FROM AssessAttempts AS aa
31+
WHERE (CandidateID = p.CandidateID) AND (CustomisationID = p.CustomisationID) AND (Status = 1)
32+
GROUP BY SectionNumber) AS derivedtbl_2), 0) AS Passes,
33+
(SELECT COUNT(SectionID) AS Sections
34+
FROM Sections AS s
35+
WHERE (ApplicationID = cu.ApplicationID)) AS Sections, p.CompleteByDate, CAST(CASE WHEN p.CompleteByDate IS NULL THEN 0 WHEN p.CompleteByDate < getDate()
36+
THEN 2 WHEN p.CompleteByDate < DATEADD(M, + 1, getDate()) THEN 1 ELSE 0 END AS INT) AS OverDue, p.EnrollmentMethodID, dbo.GetCohortGroupCustomisationID(p.ProgressID) AS GroupCustomisationID, p.SupervisorAdminID
37+
38+
FROM Progress AS p INNER JOIN
39+
Customisations AS cu ON p.CustomisationID = cu.CustomisationID INNER JOIN
40+
Applications AS a ON cu.ApplicationID = a.ApplicationID
41+
WHERE (p.Completed IS NULL) AND (p.RemovedDate IS NULL) AND (p.CandidateID = @CandidateID)AND (cu.CustomisationName <> 'ESR') AND (a.ArchivedDate IS NULL) AND (cu.Active = 1) AND (p.SubmittedTime > DATEADD(M, -6, getDate()) OR NOT p.CompleteByDate IS NULL)
42+
ORDER BY p.SubmittedTime Desc
43+
END
44+
GO
45+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/****** Object: UserDefinedFunction [dbo].[CheckDelegateStatusForCustomisation] Script Date: 16/05/2024 09:29:31 ******/
2+
SET ANSI_NULLS ON
3+
GO
4+
5+
SET QUOTED_IDENTIFIER ON
6+
GO
7+
8+
-- =============================================
9+
-- Author: Kevin Whittaker
10+
-- Create date: 22/12/2016
11+
-- Description: Checks if learner has progress record against customisation.
12+
-- Returns:
13+
-- 0: None
14+
-- 1: Expired
15+
-- 2: Complete
16+
-- 3: Current
17+
-- =============================================
18+
-- 18/09/2018 Adds return val of 4 for removed progress. Also excluded removed progress from current and expired checks.
19+
-- 17/20/2023 Excludes progress that is marked as removed from the query with a return value of 2 (Complete).
20+
ALTER FUNCTION [dbo].[CheckDelegateStatusForCustomisation]
21+
(
22+
-- Add the parameters for the function here
23+
@CustomisationID Int,
24+
@CandidateID Int
25+
)
26+
RETURNS int
27+
AS
28+
BEGIN
29+
-- Declare the return variable here
30+
DECLARE @ResultVar int
31+
Set @ResultVar = 0
32+
33+
-- Add the T-SQL statements to compute the return value here
34+
-- Check of current:
35+
if @CustomisationID IN (SELECT CustomisationID
36+
FROM Progress AS p
37+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND (SubmittedTime > DATEADD(M, - 6, GETDATE()) OR NOT p.CompleteByDate IS NULL))
38+
begin
39+
Set @ResultVar = 3
40+
goto onExit
41+
end
42+
--Check if Complete:
43+
if @CustomisationID IN (SELECT CustomisationID
44+
FROM Progress AS p
45+
WHERE (Completed IS NOT NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID))
46+
begin
47+
Set @ResultVar = 2
48+
goto onExit
49+
end
50+
--Check if Expired:
51+
if @CustomisationID IN (SELECT CustomisationID
52+
FROM Progress AS p
53+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND (SubmittedTime <= DATEADD(M, - 6, GETDATE())) AND (p.CompleteByDate IS NULL))
54+
begin
55+
Set @ResultVar = 1
56+
goto onExit
57+
end
58+
--Check if Removed:
59+
if @CustomisationID IN (SELECT CustomisationID
60+
FROM Progress AS p
61+
WHERE (Completed IS NULL) AND (RemovedDate IS NOT NULL) AND (CandidateID = @CandidateID) AND (p.CompleteByDate IS NULL))
62+
begin
63+
Set @ResultVar = 4
64+
goto onExit
65+
end
66+
-- Return the result of the function
67+
onExit:
68+
RETURN @ResultVar
69+
70+
END
71+
72+
GO
73+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
/****** Object: UserDefinedFunction [dbo].[CheckDelegateStatusForCustomisation] Script Date: 09/05/2024 11:41:58 ******/
3+
SET ANSI_NULLS ON
4+
GO
5+
SET QUOTED_IDENTIFIER ON
6+
GO
7+
-- =============================================
8+
-- Author: Kevin Whittaker
9+
-- Create date: 22/12/2016
10+
-- Description: Checks if learner has progress record against customisation.
11+
-- Returns:
12+
-- 0: None
13+
-- 1: Expired
14+
-- 2: Complete
15+
-- 3: Current
16+
-- =============================================
17+
-- 18/09/2018 Adds return val of 4 for removed progress. Also excluded removed progress from current and expired checks.
18+
-- 17/20/2023 Excludes progress that is marked as removed from the query with a return value of 2 (Complete).
19+
ALTER FUNCTION [dbo].[CheckDelegateStatusForCustomisation]
20+
(
21+
-- Add the parameters for the function here
22+
@CustomisationID Int,
23+
@CandidateID Int
24+
)
25+
RETURNS int
26+
AS
27+
BEGIN
28+
-- Declare the return variable here
29+
DECLARE @ResultVar int
30+
Set @ResultVar = 0
31+
32+
-- Add the T-SQL statements to compute the return value here
33+
34+
-- Check of current:
35+
if @CustomisationID IN (SELECT CustomisationID
36+
FROM Progress AS p
37+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime > DATEADD(M, - 6, GETDATE()) OR (EnrollmentMethodID <> 1)) OR NOT p.CompleteByDate IS NULL))
38+
begin
39+
Set @ResultVar = 3
40+
goto onExit
41+
end
42+
--Check if Complete:
43+
if @CustomisationID IN (SELECT CustomisationID
44+
FROM Progress AS p
45+
WHERE (Completed IS NOT NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID))
46+
begin
47+
Set @ResultVar = 2
48+
goto onExit
49+
end
50+
--Check if Expired:
51+
if @CustomisationID IN (SELECT CustomisationID
52+
FROM Progress AS p
53+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime <= DATEADD(M, - 6, GETDATE())) AND (EnrollmentMethodID = 1)) AND (p.CompleteByDate IS NULL))
54+
begin
55+
Set @ResultVar = 1
56+
goto onExit
57+
end
58+
--Check if Removed:
59+
if @CustomisationID IN (SELECT CustomisationID
60+
FROM Progress AS p
61+
WHERE (Completed IS NULL) AND (RemovedDate IS NOT NULL) AND (CandidateID = @CandidateID) AND (p.CompleteByDate IS NULL))
62+
begin
63+
Set @ResultVar = 4
64+
goto onExit
65+
end
66+
-- Return the result of the function
67+
onExit:
68+
RETURN @ResultVar
69+
70+
END

0 commit comments

Comments
 (0)