Skip to content

Commit 00121d9

Browse files
Auldrin-Possakevwhitt-hee
authored andcommitted
TD-4882-RoleProfiles retrieved based on logged in supervisor category
1 parent 108c416 commit 00121d9

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

DigitalLearningSolutions.Data/DataServices/SupervisorDataService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface ISupervisorDataService
2323
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedSignOffs(int adminId);
2424
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedReviews(int adminId);
2525
DelegateSelfAssessment? GetSelfAssessmentBaseByCandidateAssessmentId(int candidateAssessmentId);
26-
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId);
26+
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId);
2727
RoleProfile? GetRoleProfileById(int selfAssessmentId);
2828
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesForSelfAssessment(int selfAssessmentId);
2929
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesBySelfAssessmentIdForSupervisor(int selfAssessmentId);
@@ -738,7 +738,7 @@ public int RemoveSelfAssessmentResultSupervisorVerificationById(int id)
738738
}
739739
return numberOfAffectedRows;
740740
}
741-
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId)
741+
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId, int? categoryId)
742742
{
743743
return connection.Query<RoleProfile>(
744744
$@"SELECT rp.ID, rp.Name AS RoleProfileName, rp.Description, rp.BrandID, rp.ParentSelfAssessmentID, rp.[National], rp.[Public], rp.CreatedByAdminID AS OwnerAdminID, rp.NRPProfessionalGroupID, rp.NRPSubGroupID, rp.NRPRoleID, rp.PublishStatusID, 0 AS UserRole, rp.CreatedDate,
@@ -759,8 +759,10 @@ FROM SelfAssessments AS rp INNER JOIN
759759
WHERE (rp.ArchivedDate IS NULL) AND (rp.ID NOT IN
760760
(SELECT SelfAssessmentID
761761
FROM CandidateAssessments AS CA
762-
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL) AND (CompletedDate IS NULL))) AND ((rp.SupervisorSelfAssessmentReview = 1) OR
763-
(rp.SupervisorResultsReview = 1))", new { delegateUserId, centreId }
762+
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL)
763+
AND (CompletedDate IS NULL)))
764+
AND ((rp.SupervisorSelfAssessmentReview = 1) OR (rp.SupervisorResultsReview = 1))
765+
AND (ISNULL(@categoryId, 0) = 0 OR rp.CategoryID = @categoryId)", new { delegateUserId, centreId, categoryId }
764766
);
765767
}
766768

DigitalLearningSolutions.Data/Models/User/AdminEntity.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public override string SearchableName
5757
UserCentreDetails?.Email
5858
);
5959

60+
public int? CategoryId => AdminAccount.CategoryId;
6061
public string? CategoryName => AdminAccount.CategoryName;
6162
public bool IsLocked => UserAccount.FailedLoginCount >= AuthHelper.FailedLoginThreshold;
6263
public bool IsUserActive => UserAccount.Active;

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using DigitalLearningSolutions.Web.Extensions;
1313
using DigitalLearningSolutions.Web.Helpers;
1414
using DigitalLearningSolutions.Web.ServiceFilter;
15-
using DigitalLearningSolutions.Web.Services;
1615
using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage;
1716
using DigitalLearningSolutions.Web.ViewModels.Supervisor;
1817
using GDS.MultiPageFormData.Enums;
@@ -722,12 +721,14 @@ public IActionResult EnrolDelegateOnProfileAssessment(int supervisorDelegateId)
722721
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
723722
TempData
724723
);
724+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
725725

726726
var supervisorDelegate =
727727
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
728728
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
729729
(int)supervisorDelegate.DelegateUserID,
730-
GetCentreId()
730+
GetCentreId(),
731+
loggedInAdmin.CategoryId
731732
);
732733
var model = new EnrolDelegateOnProfileAssessmentViewModel()
733734
{
@@ -747,6 +748,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
747748
TempData
748749
).GetAwaiter().GetResult();
749750

751+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
752+
750753
if (selfAssessmentID < 1)
751754
{
752755
ModelState.AddModelError("selfAssessmentId", "You must select a self assessment");
@@ -759,7 +762,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
759762
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
760763
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
761764
(int)supervisorDelegate.DelegateUserID,
762-
GetCentreId()
765+
GetCentreId(),
766+
loggedInAdmin.CategoryId
763767
);
764768
var model = new EnrolDelegateOnProfileAssessmentViewModel()
765769
{
@@ -1391,7 +1395,7 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
13911395
}
13921396
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value,loggedInAdminUser.CategoryId);
13931397
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1394-
if ( (checkSupervisorDelegate == null) )
1398+
if ((checkSupervisorDelegate == null))
13951399
{
13961400
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13971401
}
@@ -1426,9 +1430,9 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
14261430
{
14271431
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14281432
}
1429-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value, loggedInAdminUser.CategoryId);
1430-
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1431-
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
1433+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value, loggedInAdminUser.CategoryId);
1434+
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1435+
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14321436
var delegateUserId = competencymaindata.LearnerId;
14331437
var competencycount = selfAssessmentService.GetCompetencyCountSelfAssessmentCertificate(candidateAssessmentId);
14341438
var accessors = selfAssessmentService.GetAccessor(competencymaindata.SelfAssessmentID, competencymaindata.LearnerId);

DigitalLearningSolutions.Web/Services/SupervisorService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface ISupervisorService
2020
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedSignOffs(int adminId);
2121
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedReviews(int adminId);
2222
DelegateSelfAssessment? GetSelfAssessmentBaseByCandidateAssessmentId(int candidateAssessmentId);
23-
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId);
23+
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId);
2424
RoleProfile? GetRoleProfileById(int selfAssessmentId);
2525
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesForSelfAssessment(int selfAssessmentId);
2626
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesBySelfAssessmentIdForSupervisor(int selfAssessmentId);
@@ -79,9 +79,9 @@ public int EnrolDelegateOnAssessment(int delegateUserId, int supervisorDelegateI
7979
return supervisorDataService.EnrolDelegateOnAssessment(delegateUserId, supervisorDelegateId, selfAssessmentId, completeByDate, selfAssessmentSupervisorRoleId, adminId, centreId, isLoggedInUser);
8080
}
8181

82-
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId)
82+
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId)
8383
{
84-
return supervisorDataService.GetAvailableRoleProfilesForDelegate(candidateId, centreId);
84+
return supervisorDataService.GetAvailableRoleProfilesForDelegate(candidateId, centreId, categoryId);
8585
}
8686

8787
public CandidateAssessmentSupervisor? GetCandidateAssessmentSupervisor(int candidateAssessmentID, int supervisorDelegateId, int selfAssessmentSupervisorRoleId)

0 commit comments

Comments
 (0)