Skip to content

Commit 795df56

Browse files
authored
Merge pull request #2138 from TechnologyEnhancedLearning/Develop/fix/TD-2508-hidden-in-learning-portal-should-not-appear
TD-2508- Courses that are marked as hidden in learning portal should not appear in the Available Activities list
2 parents fd6f1f6 + 90b714f commit 795df56

File tree

8 files changed

+186
-5
lines changed

8 files changed

+186
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202309141645)]
6+
public class AlterGetActivitiesForDelegateEnrolmentSPNotHiddenInLearningPortal : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_2508_GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak);
11+
}
12+
public override void Down()
13+
{
14+
Execute.Sql(Properties.Resources.TD_2508_GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak_down);
15+
}
16+
}
17+
}

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

Lines changed: 36 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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,10 @@
307307
<data name="TD_1943_CookiePolicyContentHtml" type="System.Resources.ResXFileRef, System.Windows.Forms">
308308
<value>..\Resources\TD_1943_CookiePolicyContentHtml.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
309309
</data>
310-
</root>
310+
<data name="TD_2508_GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak" type="System.Resources.ResXFileRef, System.Windows.Forms">
311+
<value>..\Scripts\TD-2508-GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
312+
</data>
313+
<data name="TD_2508_GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
314+
<value>..\Scripts\TD-2508-GetActivitiesForDelegateEnrolmentHiddenInLearningPortalTweak_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
315+
</data>
316+
</root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 05/07/2023 08:52:32 ******/
2+
SET ANSI_NULLS ON
3+
GO
4+
SET QUOTED_IDENTIFIER ON
5+
GO
6+
-- =============================================
7+
-- Author: Kevin Whittaker
8+
-- Create date: 24/01/2023
9+
-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category.
10+
-- =============================================
11+
ALTER PROCEDURE [dbo].[GetActivitiesForDelegateEnrolment]
12+
-- Add the parameters for the stored procedure here
13+
@CentreID as Int = 0,
14+
@DelegateID as int,
15+
@CategoryId as Int = 0
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+
SELECT * FROM
22+
-- Insert statements for procedure here
23+
(SELECT cu.CustomisationID, cu.Active, cu.CurrentVersion, cu.CentreID, cu.ApplicationID, (CASE WHEN cu.CustomisationName <> '' THEN a.ApplicationName + ' - ' + cu.CustomisationName ELSE a.ApplicationName END) AS CourseName, cu.CustomisationText, 0 AS IncludesSignposting, 0 AS IsSelfAssessment, cu.SelfRegister AS SelfRegister,
24+
cu.IsAssessed, dbo.CheckCustomisationSectionHasDiagnostic(cu.CustomisationID, 0) AS HasDiagnostic,
25+
dbo.CheckCustomisationSectionHasLearning(cu.CustomisationID, 0) AS HasLearning, (SELECT BrandName FROM Brands WHERE BrandID = a.BrandID) AS Brand, (SELECT CategoryName FROM CourseCategories WHERE CourseCategoryID = a.CourseCategoryID) AS Category, (SELECT CourseTopic FROM CourseTopics WHERE CourseTopicID = a.CourseTopicID) AS Topic, dbo.CheckDelegateStatusForCustomisation(cu.CustomisationID, @DelegateID) AS DelegateStatus,
26+
cu.HideInLearnerPortal
27+
FROM Customisations AS cu INNER JOIN
28+
Applications AS a
29+
ON cu.ApplicationID = a.ApplicationID
30+
WHERE ((cu.CentreID = @CentreID) OR (cu.AllCentres = 1 AND (EXISTS(SELECT CentreApplicationID FROM CentreApplications WHERE ApplicationID = a.ApplicationID AND CentreID = @CentreID AND Active = 1)))) AND
31+
(cu.Active = 1) AND
32+
(a.ASPMenu = 1) AND
33+
(a.ArchivedDate IS NULL) AND
34+
(dbo.CheckDelegateStatusForCustomisation(cu.CustomisationID, @DelegateID) IN (0,1,4)) AND
35+
(cu.CustomisationName <> 'ESR') AND
36+
(a.CourseCategoryID = @CategoryId OR @CategoryId =0)
37+
UNION ALL
38+
SELECT SA.ID AS CustomisationID, 1 AS Active, 1 AS CurrentVersion, CSA.CentreID as CentreID, 0 AS ApplicationID, SA.Name AS CourseName, SA.Description AS CustomisationText, SA.IncludesSignposting, 1 AS IsSelfAssessment, CSA.AllowEnrolment AS SelfRegister, 0 AS IsAssessed, 0 AS HasDiagnostic, 0 AS HasLearning,
39+
(SELECT BrandName
40+
FROM Brands
41+
WHERE (BrandID = SA.BrandID)) AS Brand,
42+
(SELECT CategoryName
43+
FROM CourseCategories
44+
WHERE (CourseCategoryID = SA.CategoryID)) AS Category,
45+
'' AS Topic, IIF(CA.RemovedDate IS NULL,0,1) AS DelegateStatus,
46+
null AS HideInLearnerPortal
47+
FROM SelfAssessments AS SA
48+
INNER JOIN CentreSelfAssessments AS CSA ON SA.Id = CSA.SelfAssessmentID AND CSA.CentreId = @centreId AND CSA.AllowEnrolment = 1
49+
LEFT JOIN CandidateAssessments AS CA ON CSA.SelfAssessmentID=CA.SelfAssessmentID AND CA.DelegateUserID = (SELECT UserID from DelegateAccounts where ID=@DelegateID)
50+
WHERE (SA.ID NOT IN
51+
(SELECT SelfAssessmentID
52+
FROM CandidateAssessments AS CA
53+
INNER JOIN Users AS U ON CA.DelegateUserID = U.ID
54+
INNER JOIN DelegateAccounts AS DA ON U.ID = DA.UserID
55+
WHERE (DA.ID = @DelegateID) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL))) AND
56+
(SA.CategoryID = @CategoryId OR @CategoryId =0)
57+
)
58+
AS Q1
59+
ORDER BY Q1.CourseName
60+
END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/****** Object: StoredProcedure [dbo].[GetActivitiesForDelegateEnrolment] Script Date: 05/07/2023 08:52:32 ******/
2+
SET ANSI_NULLS ON
3+
GO
4+
SET QUOTED_IDENTIFIER ON
5+
GO
6+
-- =============================================
7+
-- Author: Kevin Whittaker
8+
-- Create date: 24/01/2023
9+
-- Description: Returns active available for delegate enrolment based on original GetActiveAvailableCustomisationsForCentreFiltered_V6 sproc but adjusted for user account refactor and filters properly for category.
10+
-- =============================================
11+
ALTER PROCEDURE [dbo].[GetActivitiesForDelegateEnrolment]
12+
-- Add the parameters for the stored procedure here
13+
@CentreID as Int = 0,
14+
@DelegateID as int,
15+
@CategoryId as Int = 0
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+
SELECT * FROM
22+
-- Insert statements for procedure here
23+
(SELECT cu.CustomisationID, cu.Active, cu.CurrentVersion, cu.CentreID, cu.ApplicationID, (CASE WHEN cu.CustomisationName <> '' THEN a.ApplicationName + ' - ' + cu.CustomisationName ELSE a.ApplicationName END) AS CourseName, cu.CustomisationText, 0 AS IncludesSignposting, 0 AS IsSelfAssessment, cu.SelfRegister AS SelfRegister,
24+
cu.IsAssessed, dbo.CheckCustomisationSectionHasDiagnostic(cu.CustomisationID, 0) AS HasDiagnostic,
25+
dbo.CheckCustomisationSectionHasLearning(cu.CustomisationID, 0) AS HasLearning, (SELECT BrandName FROM Brands WHERE BrandID = a.BrandID) AS Brand, (SELECT CategoryName FROM CourseCategories WHERE CourseCategoryID = a.CourseCategoryID) AS Category, (SELECT CourseTopic FROM CourseTopics WHERE CourseTopicID = a.CourseTopicID) AS Topic, dbo.CheckDelegateStatusForCustomisation(cu.CustomisationID, @DelegateID) AS DelegateStatus
26+
FROM Customisations AS cu INNER JOIN
27+
Applications AS a
28+
ON cu.ApplicationID = a.ApplicationID
29+
WHERE ((cu.CentreID = @CentreID) OR (cu.AllCentres = 1 AND (EXISTS(SELECT CentreApplicationID FROM CentreApplications WHERE ApplicationID = a.ApplicationID AND CentreID = @CentreID AND Active = 1)))) AND
30+
(cu.Active = 1) AND
31+
(a.ASPMenu = 1) AND
32+
(a.ArchivedDate IS NULL) AND
33+
(dbo.CheckDelegateStatusForCustomisation(cu.CustomisationID, @DelegateID) IN (0,1,4)) AND
34+
(cu.CustomisationName <> 'ESR') AND
35+
(a.CourseCategoryID = @CategoryId OR @CategoryId =0)
36+
UNION ALL
37+
SELECT SA.ID AS CustomisationID, 1 AS Active, 1 AS CurrentVersion, CSA.CentreID as CentreID, 0 AS ApplicationID, SA.Name AS CourseName, SA.Description AS CustomisationText, SA.IncludesSignposting, 1 AS IsSelfAssessment, CSA.AllowEnrolment AS SelfRegister, 0 AS IsAssessed, 0 AS HasDiagnostic, 0 AS HasLearning,
38+
(SELECT BrandName
39+
FROM Brands
40+
WHERE (BrandID = SA.BrandID)) AS Brand,
41+
(SELECT CategoryName
42+
FROM CourseCategories
43+
WHERE (CourseCategoryID = SA.CategoryID)) AS Category,
44+
'' AS Topic, IIF(CA.RemovedDate IS NULL,0,1) AS DelegateStatus
45+
FROM SelfAssessments AS SA
46+
INNER JOIN CentreSelfAssessments AS CSA ON SA.Id = CSA.SelfAssessmentID AND CSA.CentreId = @centreId AND CSA.AllowEnrolment = 1
47+
LEFT JOIN CandidateAssessments AS CA ON CSA.SelfAssessmentID=CA.SelfAssessmentID AND CA.DelegateUserID = (SELECT UserID from DelegateAccounts where ID=@DelegateID)
48+
WHERE (SA.ID NOT IN
49+
(SELECT SelfAssessmentID
50+
FROM CandidateAssessments AS CA
51+
INNER JOIN Users AS U ON CA.DelegateUserID = U.ID
52+
INNER JOIN DelegateAccounts AS DA ON U.ID = DA.UserID
53+
WHERE (DA.ID = @DelegateID) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL))) AND
54+
(SA.CategoryID = @CategoryId OR @CategoryId =0)
55+
)
56+
AS Q1
57+
ORDER BY Q1.CourseName
58+
END

DigitalLearningSolutions.Data/Models/Courses/AvailableCourse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public string? Topic
1616
set => topic = GetValidOrNull(value);
1717
}
1818
public int DelegateStatus { get; set; }
19+
public bool HideInLearnerPortal { get; set; }
1920

2021
private string? category;
2122
private string? topic;

DigitalLearningSolutions.Web.Tests/TestHelpers/AvailableCourseHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public static AvailableCourse CreateDefaultAvailableCourse(
1616
string brand = "Brand 1",
1717
string? category = "Category 1",
1818
string? topic = "Topic 1",
19-
int delegateStatus = 0
19+
int delegateStatus = 0,
20+
bool hideInLearnerPortal = false
2021
)
2122
{
2223
return new AvailableCourse
@@ -29,7 +30,8 @@ public static AvailableCourse CreateDefaultAvailableCourse(
2930
Brand = brand,
3031
Category = category,
3132
Topic = topic,
32-
DelegateStatus = delegateStatus
33+
DelegateStatus = delegateStatus,
34+
HideInLearnerPortal = hideInLearnerPortal
3335
};
3436
}
3537
public static AvailablePageViewModel AvailableViewModelFromController(LearningPortalController controller)

DigitalLearningSolutions.Web/Controllers/LearningPortalController/Available.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using DigitalLearningSolutions.Web.Helpers;
77
using DigitalLearningSolutions.Web.ViewModels.LearningPortal.Available;
88
using Microsoft.AspNetCore.Mvc;
9+
using System.Linq;
910

1011
public partial class LearningPortalController
1112
{
@@ -23,7 +24,7 @@ public IActionResult Available(
2324
var availableCourses = courseDataService.GetAvailableCourses(
2425
User.GetCandidateIdKnownNotNull(),
2526
User.GetCentreIdKnownNotNull()
26-
);
27+
).Where(course => !course.HideInLearnerPortal).ToList();
2728
var bannerText = GetBannerText();
2829
var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
2930
new SearchOptions(searchString),
@@ -50,7 +51,7 @@ public IActionResult AllAvailableItems()
5051
var availableCourses = courseDataService.GetAvailableCourses(
5152
User.GetCandidateIdKnownNotNull(),
5253
User.GetCentreIdKnownNotNull()
53-
);
54+
).Where(course => !course.HideInLearnerPortal).ToList();
5455
var model = new AllAvailableItemsPageViewModel(availableCourses);
5556
return View("Available/AllAvailableItems", model);
5657
}

0 commit comments

Comments
 (0)