diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs index 20f9f52ab2..1da83a6d65 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs @@ -8,7 +8,7 @@ public partial class SelfAssessmentDataService { - public IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId) + public IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId) { return connection.Query( @"SELECT SelfAssessment.Id, @@ -67,7 +67,7 @@ Competencies AS C RIGHT OUTER JOIN CandidateAssessmentSupervisorVerifications AS casv ON casv.CandidateAssessmentSupervisorID = cas.ID LEFT OUTER JOIN AdminAccounts AS aaEnrolledBy ON aaEnrolledBy.ID = CA.EnrolledByAdminID LEFT OUTER JOIN Users AS uEnrolledBy ON uEnrolledBy.ID = aaEnrolledBy.UserID - WHERE (CA.DelegateUserID = @delegateUserId) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL) + WHERE (CA.DelegateUserID = @delegateUserId) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL) AND (ISNULL(@adminCategoryId, 0) = 0 OR sa.CategoryID = @adminCategoryId) GROUP BY CA.SelfAssessmentID, SA.Name, SA.Description, SA.IncludesSignposting, SA.SupervisorResultsReview, SA.ReviewerCommentsLabel, SA.IncludeRequirementsFilters, @@ -83,7 +83,7 @@ CandidateAssessments AS CA LEFT OUTER JOIN (casv.Verified IS NOT NULL) GROUP BY SelfAssessmentID,casv.SignedOff )Signoff ON SelfAssessment.Id =Signoff.SelfAssessmentID", - new { delegateUserId, centreId } + new { delegateUserId, centreId, adminCategoryId } ); } diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs index e10185bf18..346fa62112 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs @@ -72,7 +72,7 @@ int competencyId // CandidateAssessmentsDataService - IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId); + IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId); CurrentSelfAssessment? GetSelfAssessmentForCandidateById(int delegateUserId, int selfAssessmentId); diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs index 46c6f0685e..245c727128 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs @@ -44,7 +44,7 @@ bool apiIsAccessible var bannerText = "bannerText"; A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses); - A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(DelegateUserId, A._)).Returns(selfAssessments); + A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(DelegateUserId, A._, A._)).Returns(selfAssessments); A.CallTo(() => actionPlanService.GetIncompleteActionPlanResources(DelegateUserId)) .Returns((actionPlanResources, apiIsAccessible)); A.CallTo(() => centresService.GetBannerText(CentreId)).Returns(bannerText); @@ -426,7 +426,7 @@ public void MarkActionPlanResourceAsComplete_does_not_call_service_with_invalid_ private void GivenCurrentActivitiesAreEmptyLists() { A.CallTo(() => courseService.GetCurrentCourses(A._)).Returns(new List()); - A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(A._, A._)) + A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(A._, A._, A._)) .Returns(new List()); A.CallTo(() => actionPlanService.GetIncompleteActionPlanResources(A._)) .Returns((new List(), false)); diff --git a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs index d77ae9f556..ed30c74566 100644 --- a/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs +++ b/DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs @@ -44,7 +44,7 @@ public async Task Current( var centreId = User.GetCentreIdKnownNotNull(); var selfAssessments = - selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId); + selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0); var (learningResources, apiIsAccessible) = await GetIncompleteActionPlanResourcesIfSignpostingEnabled(delegateUserId); @@ -81,7 +81,7 @@ public async Task AllCurrentItems() var centreId = User.GetCentreIdKnownNotNull(); var selfAssessment = - selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId); + selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0); var (learningResources, _) = await GetIncompleteActionPlanResourcesIfSignpostingEnabled(delegateUserId); var model = new AllCurrentItemsPageViewModel(currentCourses, selfAssessment, learningResources); diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs index 32589d77a9..e0c157e3f2 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs @@ -81,9 +81,10 @@ public IActionResult Index(int delegateId, string? callType) course.LastUpdated = DateHelper.GetLocalDateTime(course.LastUpdated); course.Completed = course.Completed?.TimeOfDay == TimeSpan.Zero ? course.Completed : DateHelper.GetLocalDateTime(course.Completed); } + var selfAssessments = - selfAssessmentService.GetSelfAssessmentsForCandidate(delegateEntity.UserAccount.Id, centreId); + selfAssessmentService.GetSelfAssessmentsForCandidate(delegateEntity.UserAccount.Id, centreId, categoryIdFilter); foreach (var selfassessment in selfAssessments) { diff --git a/DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs b/DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs index 61e92bb72b..102af0b0b1 100644 --- a/DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs +++ b/DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs @@ -15,7 +15,7 @@ public interface ISelfAssessmentService //Self Assessments string? GetSelfAssessmentNameById(int selfAssessmentId); // Candidate Assessments - IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId); + IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId); CurrentSelfAssessment? GetSelfAssessmentForCandidateById(int delegateUserId, int selfAssessmentId); @@ -404,9 +404,9 @@ public IEnumerable GetCandidateAssessmentOptionalCompetencies(int se return selfAssessmentDataService.GetCandidateAssessmentOptionalCompetencies(selfAssessmentId, delegateUserId); } - public IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId) + public IEnumerable GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId) { - return selfAssessmentDataService.GetSelfAssessmentsForCandidate(delegateUserId, centreId); + return selfAssessmentDataService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, adminCategoryId); } public IEnumerable GetMostRecentResults(int selfAssessmentId, int delegateId)