Skip to content

Commit 5f07d7a

Browse files
committed
Revert "Revert "TD-2180 - query param added to reuse query in the course setup.""
This reverts commit 011fbb0.
1 parent 8130860 commit 5f07d7a

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public IEnumerable<CourseStatistics> GetCourseStatisticsAtCentreFilteredByCatego
623623
);
624624
}
625625

626-
public (IEnumerable<CourseStatistics>, int) GetCourseStatisticsAtCentre(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId,
626+
public (IEnumerable<CourseStatistics>, int) GetCourseStatisticsAtCentre(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId, bool allCentreCourses, bool? hideInLearnerPortal,
627627
string isActive, string categoryName, string courseTopic, string hasAdminFields
628628
)
629629
{
@@ -671,7 +671,7 @@ LEFT JOIN CoursePrompts AS cp3 WITH (NOLOCK)
671671
ON cu.CourseField3PromptID = cp3.CoursePromptID
672672
673673
WHERE (ap.CourseCategoryID = @categoryId OR @categoryId IS NULL)
674-
AND (cu.CentreID = @centreId OR (cu.AllCentres = 1 AND ca.Active = 1))
674+
AND (cu.CentreID = @centreId OR (cu.AllCentres = 1 AND ca.Active = @allCentreCourses))
675675
AND ca.CentreID = @centreId
676676
AND ap.DefaultContentTypeID <> 4
677677
AND ( ap.ApplicationName + ' ' + ' ' + cu.CustomisationName LIKE N'%' + @searchString + N'%')
@@ -681,6 +681,8 @@ AND ap.DefaultContentTypeID <> 4
681681
AND ((@hasAdminFields = 'Any') OR (@hasAdminFields = 'true' AND (cp1.CoursePrompt IS NOT NULL OR cp2.CoursePrompt IS NOT NULL OR cp3.CoursePrompt IS NOT NULL))
682682
OR (@hasAdminFields = 'false' AND (cp1.CoursePrompt IS NULL AND cp2.CoursePrompt IS NULL AND cp3.CoursePrompt IS NULL)))";
683683

684+
if (hideInLearnerPortal != null)
685+
courseStatisticsFromTable += " AND cu.HideInLearnerPortal = @hideInLearnerPortal";
684686

685687
string orderBy;
686688
string sortOrder;
@@ -710,6 +712,8 @@ AND ap.DefaultContentTypeID <> 4
710712
sortDirection,
711713
centreId,
712714
categoryId,
715+
allCentreCourses,
716+
hideInLearnerPortal,
713717
isActive,
714718
categoryName,
715719
courseTopic,
@@ -731,6 +735,8 @@ AND ap.DefaultContentTypeID <> 4
731735
sortDirection,
732736
centreId,
733737
categoryId,
738+
allCentreCourses,
739+
hideInLearnerPortal,
734740
isActive,
735741
categoryName,
736742
courseTopic,

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/DelegateCoursesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ public IActionResult Index(
130130
}
131131
}
132132

133-
var (courses, resultCount)= courseService.GetCentreCourses(searchString ?? string.Empty, offSet, (int)itemsPerPage, sortBy, sortDirection, centreId, categoryId,
133+
var (courses, resultCount)= courseService.GetCentreCourses(searchString ?? string.Empty, offSet, (int)itemsPerPage, sortBy, sortDirection, centreId, categoryId, true,null,
134134
isActive, categoryName, courseTopic, hasAdminFields);
135135
if (courses.Count() == 0 && resultCount > 0)
136136
{
137137
page = 1;
138138
offSet = 0;
139-
(courses, resultCount) = courseService.GetCentreCourses(searchString ?? string.Empty, offSet, (int)itemsPerPage, sortBy, sortDirection, centreId, categoryId,
139+
(courses, resultCount) = courseService.GetCentreCourses(searchString ?? string.Empty, offSet, (int)itemsPerPage, sortBy, sortDirection, centreId, categoryId, true,null,
140140
isActive, categoryName, courseTopic, hasAdminFields);
141141
}
142142

DigitalLearningSolutions.Web/Services/CourseService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using DigitalLearningSolutions.Data.Models;
88
using DigitalLearningSolutions.Data.Models.Courses;
99
using DigitalLearningSolutions.Data.Utilities;
10+
using DocumentFormat.OpenXml.Spreadsheet;
1011

1112
public interface ICourseService
1213
{
@@ -102,7 +103,7 @@ int diagCompletionThreshold
102103

103104
LearningLog? GetLearningLogDetails(int progressId);
104105

105-
public (IEnumerable<CourseStatisticsWithAdminFieldResponseCounts>, int) GetCentreCourses(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId,
106+
public (IEnumerable<CourseStatisticsWithAdminFieldResponseCounts>, int) GetCentreCourses(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId, bool allCentreCourses, bool? hideInLearnerPortal,
106107
string isActive, string categoryName, string courseTopic, string hasAdminFields);
107108
}
108109

@@ -365,10 +366,10 @@ public CentreCourseDetails GetCentreCourseDetails(int centreId, int? categoryId)
365366

366367

367368

368-
public (IEnumerable<CourseStatisticsWithAdminFieldResponseCounts>, int) GetCentreCourses(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId,
369+
public (IEnumerable<CourseStatisticsWithAdminFieldResponseCounts>, int) GetCentreCourses(string searchString, int offSet, int itemsPerPage, string sortBy, string sortDirection, int centreId, int? categoryId, bool allCentreCourses, bool? hideInLearnerPortal,
369370
string isActive, string categoryName, string courseTopic, string hasAdminFields)
370371
{
371-
var (allCourses, resultCount) = courseDataService.GetCourseStatisticsAtCentre(searchString, offSet, itemsPerPage, sortBy, sortDirection, centreId, categoryId,
372+
var (allCourses, resultCount) = courseDataService.GetCourseStatisticsAtCentre(searchString, offSet, itemsPerPage, sortBy, sortDirection, centreId, categoryId, allCentreCourses, hideInLearnerPortal,
372373
isActive, categoryName, courseTopic, hasAdminFields);
373374

374375
return (allCourses.Select(

0 commit comments

Comments
 (0)