Skip to content

Commit 7c9d551

Browse files
Auldrin-Possakevwhitt-hee
authored andcommitted
TD-4882-RoleProfiles retrieved based on logged in supervisor category
1 parent 4888394 commit 7c9d551

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
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: 14 additions & 13 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;
@@ -60,7 +59,7 @@ public IActionResult MyStaffList(
6059
var supervisorEmail = GetUserEmail();
6160
var loggedInAdminUser = userService.GetAdminUserById(adminId);
6261
var centreRegistrationPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
63-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId);
62+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId);
6463
var isSupervisor = User.GetCustomClaimAsBool(CustomClaimTypes.IsSupervisor) ?? false;
6564
var allSupervisorDelegateDetailViewModels = supervisorDelegateDetails.Select(
6665
supervisor =>
@@ -338,9 +337,8 @@ public IActionResult AllStaffList()
338337
var adminId = GetAdminId();
339338
var centreId = GetCentreId();
340339
var loggedInUserId = User.GetUserId();
341-
var loggedInAdminUser = userService.GetAdminUserById(adminId);
342340
var centreCustomPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
343-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId,loggedInAdminUser.CategoryId)
341+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId)
344342
.Select(supervisor =>
345343
{
346344
return supervisor;
@@ -718,12 +716,14 @@ public IActionResult EnrolDelegateOnProfileAssessment(int supervisorDelegateId)
718716
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
719717
TempData
720718
);
719+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
721720

722721
var supervisorDelegate =
723722
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
724723
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
725724
(int)supervisorDelegate.DelegateUserID,
726-
GetCentreId()
725+
GetCentreId(),
726+
loggedInAdmin.CategoryId
727727
);
728728
var model = new EnrolDelegateOnProfileAssessmentViewModel()
729729
{
@@ -743,6 +743,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
743743
TempData
744744
).GetAwaiter().GetResult();
745745

746+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
747+
746748
if (selfAssessmentID < 1)
747749
{
748750
ModelState.AddModelError("selfAssessmentId", "You must select a self assessment");
@@ -755,7 +757,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
755757
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
756758
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
757759
(int)supervisorDelegate.DelegateUserID,
758-
GetCentreId()
760+
GetCentreId(),
761+
loggedInAdmin.CategoryId
759762
);
760763
var model = new EnrolDelegateOnProfileAssessmentViewModel()
761764
{
@@ -1379,15 +1382,14 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
13791382
{
13801383
var adminId = User.GetAdminId();
13811384
User.GetUserIdKnownNotNull();
1382-
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
13831385
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
13841386
if ((competencymaindata == null) || (candidateAssessmentId == 0))
13851387
{
13861388
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13871389
}
1388-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value,loggedInAdminUser.CategoryId);
1390+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
13891391
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1390-
if ( (checkSupervisorDelegate == null) )
1392+
if ((checkSupervisorDelegate == null))
13911393
{
13921394
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13931395
}
@@ -1416,15 +1418,14 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
14161418
PdfReportStatusResponse pdfReportStatusResponse = new PdfReportStatusResponse();
14171419
var delegateId = User.GetCandidateIdKnownNotNull();
14181420
var adminId = User.GetAdminId();
1419-
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
14201421
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
14211422
if (competencymaindata == null || candidateAssessmentId == 0 || adminId == 0)
14221423
{
14231424
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14241425
}
1425-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value, loggedInAdminUser.CategoryId);
1426-
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1427-
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
1426+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1427+
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1428+
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14281429
var delegateUserId = competencymaindata.LearnerId;
14291430
var competencycount = selfAssessmentService.GetCompetencyCountSelfAssessmentCertificate(candidateAssessmentId);
14301431
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)