Skip to content

Commit aebc2f8

Browse files
sherif-olaboyekevwhitt-hee
authored andcommitted
TD-4881 Limit the supervisor My Staff view self assessment counts to include only those in their assigned category
1 parent 8c5d66e commit aebc2f8

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
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);
@@ -160,7 +160,7 @@ FROM CandidateAssessmentSupervisors AS cas INNER JOIN
160160
).FirstOrDefault();
161161
}
162162

163-
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId)
163+
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID)
164164
{
165165
return connection.Query<SupervisorDelegateDetail>(
166166
$@"SELECT sd.ID,
@@ -179,7 +179,9 @@ FROM CandidateAssessments AS ca LEFT JOIN
179179
CandidateAssessmentSupervisors AS cas ON cas.CandidateAssessmentID = ca.ID AND cas.Removed IS NULL AND cas.SupervisorDelegateId = sd.ID INNER JOIN
180180
SelfAssessments AS sa ON sa.ID = ca.SelfAssessmentID
181181
WHERE (ca.RemovedDate IS NULL) AND (ca.DelegateUserID=sd.DelegateUserID) AND (cas.SupervisorDelegateId = sd.ID OR (cas.CandidateAssessmentID IS NULL)
182-
AND ((sa.SupervisorSelfAssessmentReview = 1) OR (sa.SupervisorResultsReview = 1)))) AS CandidateAssessmentCount,
182+
AND ((sa.SupervisorSelfAssessmentReview = 1) OR (sa.SupervisorResultsReview = 1)))
183+
AND (ISNULL(@adminIdCategoryID, 0) = 0 OR sa.CategoryID = @adminIdCategoryID)
184+
) AS CandidateAssessmentCount,
183185
CAST(COALESCE (au2.IsNominatedSupervisor, 0) AS Bit) AS DelegateIsNominatedSupervisor,
184186
CAST(COALESCE (au2.IsSupervisor, 0) AS Bit) AS DelegateIsSupervisor,
185187
da.ID AS Expr1
@@ -212,7 +214,7 @@ LEFT OUTER JOIN AdminAccounts AS au2
212214
WHERE (sd.SupervisorAdminID = @adminId) AND (sd.Removed IS NULL) AND
213215
(u.ID = da.UserID OR sd.DelegateUserID IS NULL)
214216
ORDER BY u.LastName, COALESCE (u.FirstName, sd.DelegateEmail)
215-
", new { adminId }
217+
", new { adminId, adminIdCategoryID }
216218
);
217219
}
218220

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public IActionResult MyStaffList(
5959
var centreId = GetCentreId();
6060
var supervisorEmail = GetUserEmail();
6161
var loggedInAdminUser = userService.GetAdminUserById(adminId);
62-
var centreRegistrationPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
63-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId);
62+
var centreRegistrationPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
63+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId, loggedInAdminUser.CategoryId);
6464
if (!supervisorDelegateDetails.Any())
6565
{
6666
supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminIdWithoutRemovedClause(adminId);
@@ -342,8 +342,9 @@ public IActionResult AllStaffList()
342342
var adminId = GetAdminId();
343343
var centreId = GetCentreId();
344344
var loggedInUserId = User.GetUserId();
345+
var loggedInAdminUser = userService.GetAdminUserById(adminId);
345346
var centreCustomPrompts = centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId);
346-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId)
347+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId,loggedInAdminUser.CategoryId)
347348
.Select(supervisor =>
348349
{
349350
return supervisor;
@@ -1382,12 +1383,13 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
13821383
{
13831384
var adminId = User.GetAdminId();
13841385
User.GetUserIdKnownNotNull();
1386+
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
13851387
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
13861388
if ((competencymaindata == null) || (candidateAssessmentId == 0))
13871389
{
13881390
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
13891391
}
1390-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1392+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value,loggedInAdminUser.CategoryId);
13911393
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
13921394
if ( (checkSupervisorDelegate == null) )
13931395
{
@@ -1418,12 +1420,13 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
14181420
PdfReportStatusResponse pdfReportStatusResponse = new PdfReportStatusResponse();
14191421
var delegateId = User.GetCandidateIdKnownNotNull();
14201422
var adminId = User.GetAdminId();
1423+
var loggedInAdminUser = userService.GetAdminUserById(adminId.Value);
14211424
var competencymaindata = selfAssessmentService.GetCompetencySelfAssessmentCertificate(candidateAssessmentId);
14221425
if (competencymaindata == null || candidateAssessmentId == 0 || adminId == 0)
14231426
{
14241427
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14251428
}
1426-
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
1429+
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value, loggedInAdminUser.CategoryId);
14271430
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
14281431
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
14291432
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);
@@ -169,9 +169,9 @@ public SupervisorDelegateDetail GetSupervisorDelegateDetailsById(int supervisorD
169169
return supervisorDataService.GetSupervisorDelegateDetailsById(supervisorDelegateId, adminId, delegateUserId);
170170
}
171171

172-
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId)
172+
public IEnumerable<SupervisorDelegateDetail> GetSupervisorDelegateDetailsForAdminId(int adminId, int? adminIdCategoryID)
173173
{
174-
return supervisorDataService.GetSupervisorDelegateDetailsForAdminId(adminId);
174+
return supervisorDataService.GetSupervisorDelegateDetailsForAdminId(adminId, adminIdCategoryID);
175175
}
176176

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

0 commit comments

Comments
 (0)