Skip to content

Commit 45a1b37

Browse files
committed
TD-5026 limit the self assessments in the manage delegate section based on the categoryID of the user logged in.
1 parent 99a3bb9 commit 45a1b37

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public partial class SelfAssessmentDataService
1010
{
11-
public IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId)
11+
public IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId)
1212
{
1313
return connection.Query<CurrentSelfAssessment>(
1414
@"SELECT SelfAssessment.Id,
@@ -67,7 +67,7 @@ Competencies AS C RIGHT OUTER JOIN
6767
CandidateAssessmentSupervisorVerifications AS casv ON casv.CandidateAssessmentSupervisorID = cas.ID LEFT OUTER JOIN
6868
AdminAccounts AS aaEnrolledBy ON aaEnrolledBy.ID = CA.EnrolledByAdminID LEFT OUTER JOIN
6969
Users AS uEnrolledBy ON uEnrolledBy.ID = aaEnrolledBy.UserID
70-
WHERE (CA.DelegateUserID = @delegateUserId) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL)
70+
WHERE (CA.DelegateUserID = @delegateUserId) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL) AND (ISNULL(@adminCategoryId, 0) = 0 OR sa.CategoryID = @adminCategoryId)
7171
GROUP BY
7272
CA.SelfAssessmentID, SA.Name, SA.Description, SA.IncludesSignposting, SA.SupervisorResultsReview,
7373
SA.ReviewerCommentsLabel, SA.IncludeRequirementsFilters,
@@ -83,7 +83,7 @@ CandidateAssessments AS CA LEFT OUTER JOIN
8383
(casv.Verified IS NOT NULL)
8484
GROUP BY SelfAssessmentID,casv.SignedOff
8585
)Signoff ON SelfAssessment.Id =Signoff.SelfAssessmentID",
86-
new { delegateUserId, centreId }
86+
new { delegateUserId, centreId, adminCategoryId }
8787
);
8888
}
8989

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int competencyId
7272

7373
// CandidateAssessmentsDataService
7474

75-
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId);
75+
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId);
7676

7777
CurrentSelfAssessment? GetSelfAssessmentForCandidateById(int delegateUserId, int selfAssessmentId);
7878

DigitalLearningSolutions.Web.Tests/Controllers/LearningPortal/CurrentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool apiIsAccessible
4444

4545
var bannerText = "bannerText";
4646
A.CallTo(() => courseService.GetCurrentCourses(CandidateId)).Returns(currentCourses);
47-
A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(DelegateUserId, A<int>._)).Returns(selfAssessments);
47+
A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(DelegateUserId, A<int>._, A<int>._)).Returns(selfAssessments);
4848
A.CallTo(() => actionPlanService.GetIncompleteActionPlanResources(DelegateUserId))
4949
.Returns((actionPlanResources, apiIsAccessible));
5050
A.CallTo(() => centresService.GetBannerText(CentreId)).Returns(bannerText);
@@ -426,7 +426,7 @@ public void MarkActionPlanResourceAsComplete_does_not_call_service_with_invalid_
426426
private void GivenCurrentActivitiesAreEmptyLists()
427427
{
428428
A.CallTo(() => courseService.GetCurrentCourses(A<int>._)).Returns(new List<CurrentCourse>());
429-
A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(A<int>._, A<int>._))
429+
A.CallTo(() => selfAssessmentService.GetSelfAssessmentsForCandidate(A<int>._, A<int>._, A<int>._))
430430
.Returns(new List<CurrentSelfAssessment>());
431431
A.CallTo(() => actionPlanService.GetIncompleteActionPlanResources(A<int>._))
432432
.Returns((new List<ActionPlanResource>(), false));

DigitalLearningSolutions.Web/Controllers/LearningPortalController/Current.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public async Task<IActionResult> Current(
4444

4545
var centreId = User.GetCentreIdKnownNotNull();
4646
var selfAssessments =
47-
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId);
47+
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0);
4848

4949
var (learningResources, apiIsAccessible) =
5050
await GetIncompleteActionPlanResourcesIfSignpostingEnabled(delegateUserId);
@@ -81,7 +81,7 @@ public async Task<IActionResult> AllCurrentItems()
8181
var centreId = User.GetCentreIdKnownNotNull();
8282

8383
var selfAssessment =
84-
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId);
84+
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, 0);
8585

8686
var (learningResources, _) = await GetIncompleteActionPlanResourcesIfSignpostingEnabled(delegateUserId);
8787
var model = new AllCurrentItemsPageViewModel(currentCourses, selfAssessment, learningResources);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ public IActionResult Index(int delegateId, string? callType)
8181
course.LastUpdated = DateHelper.GetLocalDateTime(course.LastUpdated);
8282
course.Completed = course.Completed?.TimeOfDay == TimeSpan.Zero ? course.Completed : DateHelper.GetLocalDateTime(course.Completed);
8383
}
84+
8485

8586
var selfAssessments =
86-
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateEntity.UserAccount.Id, centreId);
87+
selfAssessmentService.GetSelfAssessmentsForCandidate(delegateEntity.UserAccount.Id, centreId, categoryIdFilter);
8788

8889
foreach (var selfassessment in selfAssessments)
8990
{

DigitalLearningSolutions.Web/Services/SelfAssessmentService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface ISelfAssessmentService
1515
//Self Assessments
1616
string? GetSelfAssessmentNameById(int selfAssessmentId);
1717
// Candidate Assessments
18-
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId);
18+
IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId);
1919

2020
CurrentSelfAssessment? GetSelfAssessmentForCandidateById(int delegateUserId, int selfAssessmentId);
2121

@@ -404,9 +404,9 @@ public IEnumerable<Competency> GetCandidateAssessmentOptionalCompetencies(int se
404404
return selfAssessmentDataService.GetCandidateAssessmentOptionalCompetencies(selfAssessmentId, delegateUserId);
405405
}
406406

407-
public IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId)
407+
public IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int delegateUserId, int centreId, int? adminCategoryId)
408408
{
409-
return selfAssessmentDataService.GetSelfAssessmentsForCandidate(delegateUserId, centreId);
409+
return selfAssessmentDataService.GetSelfAssessmentsForCandidate(delegateUserId, centreId, adminCategoryId);
410410
}
411411

412412
public IEnumerable<Competency> GetMostRecentResults(int selfAssessmentId, int delegateId)

0 commit comments

Comments
 (0)