Skip to content

Commit 1e49356

Browse files
TD-4881 Limit the supervisor My Staff view self assessment counts to include only those in their assigned category
1 parent de21044 commit 1e49356

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

DigitalLearningSolutions.Data/DataServices/SupervisorDataService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface ISupervisorDataService
1414
{
1515
//GET DATA
1616
DashboardData? GetDashboardDataForAdminId(int adminId);
17-
IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId);
17+
IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID);
1818
SupervisorDelegateDetail GetSupervisorDelegateDetailsById(int supervisorDelegateId, int adminId, int delegateUserId);
1919
SupervisorDelegate GetSupervisorDelegate(int adminId, int delegateUserId);
2020
int? ValidateDelegate(int centreId, string delegateEmail);
@@ -158,7 +158,7 @@ FROM CandidateAssessmentSupervisors AS cas INNER JOIN
158158
).FirstOrDefault();
159159
}
160160

161-
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId)
161+
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID)
162162
{
163163
return connection.Query<SupervisorDelegateDetail>(
164164
$@"SELECT sd.ID,
@@ -177,7 +177,9 @@ FROM CandidateAssessments AS ca LEFT JOIN
177177
CandidateAssessmentSupervisors AS cas ON cas.CandidateAssessmentID = ca.ID AND cas.Removed IS NULL AND cas.SupervisorDelegateId = sd.ID INNER JOIN
178178
SelfAssessments AS sa ON sa.ID = ca.SelfAssessmentID
179179
WHERE (ca.RemovedDate IS NULL) AND (ca.DelegateUserID=sd.DelegateUserID) AND (cas.SupervisorDelegateId = sd.ID OR (cas.CandidateAssessmentID IS NULL)
180-
AND ((sa.SupervisorSelfAssessmentReview = 1) OR (sa.SupervisorResultsReview = 1)))) AS CandidateAssessmentCount,
180+
AND ((sa.SupervisorSelfAssessmentReview = 1) OR (sa.SupervisorResultsReview = 1)))
181+
AND (ISNULL(@adminIdCategoryID, 0) = 0 OR sa.CategoryID = @adminIdCategoryID)
182+
) AS CandidateAssessmentCount,
181183
CAST(COALESCE (au2.IsNominatedSupervisor, 0) AS Bit) AS DelegateIsNominatedSupervisor,
182184
CAST(COALESCE (au2.IsSupervisor, 0) AS Bit) AS DelegateIsSupervisor,
183185
da.ID AS Expr1
@@ -210,7 +212,7 @@ LEFT OUTER JOIN AdminAccounts AS au2
210212
WHERE (sd.SupervisorAdminID = @adminId) AND (sd.Removed IS NULL) AND
211213
(u.ID = da.UserID OR sd.DelegateUserID IS NULL)
212214
ORDER BY u.LastName, COALESCE (u.FirstName, sd.DelegateEmail)
213-
", new { adminId }
215+
", new { adminId, adminIdCategoryID }
214216
);
215217
}
216218

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public IActionResult MyStaffList(
6060
var supervisorEmail = GetUserEmail();
6161
var loggedInAdminUser = userService.GetAdminUserById(adminId);
6262
var centreRegistrationPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
63-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId);
63+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId);
6464
var isSupervisor = User.GetCustomClaimAsBool(CustomClaimTypes.IsSupervisor) ?? false;
6565
var allSupervisorDelegateDetailViewModels = supervisorDelegateDetails.Select(
6666
supervisor =>
@@ -338,8 +338,9 @@ public IActionResult AllStaffList()
338338
var adminId = GetAdminId();
339339
var centreId = GetCentreId();
340340
var loggedInUserId = User.GetUserId();
341+
var loggedInAdminUser = userService.GetAdminUserById(adminId);
341342
var centreCustomPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
342-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId)
343+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId,loggedInAdminUser.CategoryId)
343344
.Select(supervisor =>
344345
{
345346
return supervisor;
@@ -1378,12 +1379,13 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
13781379
{
13791380
var adminId = User.GetAdminId();
13801381
User.GetUserIdKnownNotNull();
1382+
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
13811383
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
13821384
if ((competencymaindata == null) || (candidateAssessmentId == 0))
13831385
{
13841386
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13851387
}
1386-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1388+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value,loggedInAdminUser.CategoryId);
13871389
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
13881390
if ( (checkSupervisorDelegate == null) )
13891391
{
@@ -1414,12 +1416,13 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
14141416
PdfReportStatusResponse pdfReportStatusResponse = new PdfReportStatusResponse();
14151417
var delegateId = User.GetCandidateIdKnownNotNull();
14161418
var adminId = User.GetAdminId();
1419+
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
14171420
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
14181421
if (competencymaindata == null || candidateAssessmentId == 0 || adminId == 0)
14191422
{
14201423
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14211424
}
1422-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1425+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value, loggedInAdminUser.CategoryId);
14231426
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
14241427
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14251428
var delegateUserId = competencymaindata.LearnerId;

DigitalLearningSolutions.Web/Services/SupervisorService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface ISupervisorService
1111
{
1212
//GET DATA
1313
DashboardData? GetDashboardDataForAdminId(int adminId);
14-
IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId);
14+
IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID);
1515
SupervisorDelegateDetail GetSupervisorDelegateDetailsById(int supervisorDelegateId, int adminId, int delegateUserId);
1616
SupervisorDelegate GetSupervisorDelegate(int adminId, int delegateUserId);
1717
int? ValidateDelegate(int centreId, string delegateEmail);
@@ -167,9 +167,9 @@ public SupervisorDelegateDetail GetSupervisorDelegateDetailsById(int supervisorD
167167
return supervisorDataService.GetSupervisorDelegateDetailsById(supervisorDelegateId, adminId, delegateUserId);
168168
}
169169

170-
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId)
170+
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID)
171171
{
172-
return supervisorDataService.GetSupervisorDelegateDetailsForAdminId(adminId);
172+
return supervisorDataService.GetSupervisorDelegateDetailsForAdminId(adminId, adminIdCategoryID);
173173
}
174174

175175
public IEnumerable<SupervisorForEnrolDelegate> GetSupervisorForEnrolDelegate(int CustomisationID, int CentreID)

0 commit comments

Comments
 (0)