Skip to content

Commit efb4e1c

Browse files
committed
TD-4882-RoleProfiles retrieved based on logged in supervisor category
1 parent de21044 commit efb4e1c

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);
@@ -636,7 +636,7 @@ public int RemoveSelfAssessmentResultSupervisorVerificationById(int id)
636636
}
637637
return numberOfAffectedRows;
638638
}
639-
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId)
639+
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId, int? categoryId)
640640
{
641641
return connection.Query<RoleProfile>(
642642
$@"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,
@@ -657,8 +657,10 @@ FROM SelfAssessments AS rp INNER JOIN
657657
WHERE (rp.ArchivedDate IS NULL) AND (rp.ID NOT IN
658658
(SELECT SelfAssessmentID
659659
FROM CandidateAssessments AS CA
660-
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL) AND (CompletedDate IS NULL))) AND ((rp.SupervisorSelfAssessmentReview = 1) OR
661-
(rp.SupervisorResultsReview = 1))", new { delegateUserId, centreId }
660+
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL)
661+
AND (CompletedDate IS NULL)))
662+
AND ((rp.SupervisorSelfAssessmentReview = 1) OR (rp.SupervisorResultsReview = 1))
663+
AND (ISNULL(@categoryId, 0) = 0 OR rp.CategoryID = @categoryId)", new { delegateUserId, centreId, categoryId }
662664
);
663665
}
664666

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;
@@ -717,12 +716,14 @@ public IActionResult EnrolDelegateOnProfileAssessment(int supervisorDelegateId)
717716
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
718717
TempData
719718
);
719+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
720720

721721
var supervisorDelegate =
722722
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
723723
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
724724
(int)supervisorDelegate.DelegateUserID,
725-
GetCentreId()
725+
GetCentreId(),
726+
loggedInAdmin.CategoryId
726727
);
727728
var model = new EnrolDelegateOnProfileAssessmentViewModel()
728729
{
@@ -742,6 +743,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
742743
TempData
743744
).GetAwaiter().GetResult();
744745

746+
var loggedInAdmin = userService.GetAdminById(GetAdminId());
747+
745748
if (selfAssessmentID < 1)
746749
{
747750
ModelState.AddModelError("selfAssessmentId", "You must select a self assessment");
@@ -754,7 +757,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
754757
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
755758
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
756759
(int)supervisorDelegate.DelegateUserID,
757-
GetCentreId()
760+
GetCentreId(),
761+
loggedInAdmin.CategoryId
758762
);
759763
var model = new EnrolDelegateOnProfileAssessmentViewModel()
760764
{
@@ -1385,7 +1389,7 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
13851389
}
13861390
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
13871391
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1388-
if ( (checkSupervisorDelegate == null) )
1392+
if ((checkSupervisorDelegate == null))
13891393
{
13901394
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13911395
}
@@ -1419,9 +1423,9 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
14191423
{
14201424
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14211425
}
1422-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1423-
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
1424-
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 });
14251429
var delegateUserId = competencymaindata.LearnerId;
14261430
var competencycount = selfAssessmentService.GetCompetencyCountSelfAssessmentCertificate(candidateAssessmentId);
14271431
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);
@@ -77,9 +77,9 @@ public int EnrolDelegateOnAssessment(int delegateUserId, int supervisorDelegateI
7777
return supervisorDataService.EnrolDelegateOnAssessment(delegateUserId, supervisorDelegateId, selfAssessmentId, completeByDate, selfAssessmentSupervisorRoleId, adminId, centreId, isLoggedInUser);
7878
}
7979

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

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

0 commit comments

Comments
 (0)