Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface ISupervisorDataService
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedSignOffs(int adminId);
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedReviews(int adminId);
DelegateSelfAssessment? GetSelfAssessmentBaseByCandidateAssessmentId(int candidateAssessmentId);
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId);
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId);
RoleProfile? GetRoleProfileById(int selfAssessmentId);
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesForSelfAssessment(int selfAssessmentId);
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesBySelfAssessmentIdForSupervisor(int selfAssessmentId);
Expand Down Expand Up @@ -636,7 +636,7 @@ public int RemoveSelfAssessmentResultSupervisorVerificationById(int id)
}
return numberOfAffectedRows;
}
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId)
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId, int? categoryId)
{
return connection.Query<RoleProfile>(
$@"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,
Expand All @@ -657,8 +657,10 @@ FROM SelfAssessments AS rp INNER JOIN
WHERE (rp.ArchivedDate IS NULL) AND (rp.ID NOT IN
(SELECT SelfAssessmentID
FROM CandidateAssessments AS CA
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL) AND (CompletedDate IS NULL))) AND ((rp.SupervisorSelfAssessmentReview = 1) OR
(rp.SupervisorResultsReview = 1))", new { delegateUserId, centreId }
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL)
AND (CompletedDate IS NULL)))
AND ((rp.SupervisorSelfAssessmentReview = 1) OR (rp.SupervisorResultsReview = 1))
AND (ISNULL(@categoryId, 0) = 0 OR rp.CategoryID = @categoryId)", new { delegateUserId, centreId, categoryId }
);
}

Expand Down
1 change: 1 addition & 0 deletions DigitalLearningSolutions.Data/Models/User/AdminEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public override string SearchableName
UserCentreDetails?.Email
);

public int? CategoryId => AdminAccount.CategoryId;
public string? CategoryName => AdminAccount.CategoryName;
public bool IsLocked => UserAccount.FailedLoginCount >= AuthHelper.FailedLoginThreshold;
public bool IsUserActive => UserAccount.Active;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using DigitalLearningSolutions.Web.Extensions;
using DigitalLearningSolutions.Web.Helpers;
using DigitalLearningSolutions.Web.ServiceFilter;
using DigitalLearningSolutions.Web.Services;
using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage;
using DigitalLearningSolutions.Web.ViewModels.Supervisor;
using GDS.MultiPageFormData.Enums;
Expand Down Expand Up @@ -717,12 +716,14 @@ public IActionResult EnrolDelegateOnProfileAssessment(int supervisorDelegateId)
MultiPageFormDataFeature.EnrolDelegateOnProfileAssessment,
TempData
);
var loggedInAdmin = userService.GetAdminById(GetAdminId());

var supervisorDelegate =
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
(int)supervisorDelegate.DelegateUserID,
GetCentreId()
GetCentreId(),
loggedInAdmin.CategoryId
);
var model = new EnrolDelegateOnProfileAssessmentViewModel()
{
Expand All @@ -742,6 +743,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
TempData
).GetAwaiter().GetResult();

var loggedInAdmin = userService.GetAdminById(GetAdminId());

if (selfAssessmentID < 1)
{
ModelState.AddModelError("selfAssessmentId", "You must select a self assessment");
Expand All @@ -754,7 +757,8 @@ public IActionResult EnrolSetRoleProfile(int supervisorDelegateId, int selfAsses
supervisorService.GetSupervisorDelegateDetailsById(supervisorDelegateId, GetAdminId(), 0);
var roleProfiles = supervisorService.GetAvailableRoleProfilesForDelegate(
(int)supervisorDelegate.DelegateUserID,
GetCentreId()
GetCentreId(),
loggedInAdmin.CategoryId
);
var model = new EnrolDelegateOnProfileAssessmentViewModel()
{
Expand Down Expand Up @@ -1385,7 +1389,7 @@ public IActionResult CompetencySelfAssessmentCertificatesupervisor(int candidate
}
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
if ( (checkSupervisorDelegate == null) )
if ((checkSupervisorDelegate == null))
{
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
}
Expand Down Expand Up @@ -1419,9 +1423,9 @@ public async Task<IActionResult> DownloadCertificate(int candidateAssessmentId)
{
return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
}
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
var supervisorDelegateDetails = supervisorService.GetSupervisorDelegateDetailsForAdminId(adminId.Value);
var checkSupervisorDelegate = supervisorDelegateDetails.Where(x => x.DelegateUserID == competencymaindata.LearnerId).FirstOrDefault();
if (checkSupervisorDelegate == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 403 });
var delegateUserId = competencymaindata.LearnerId;
var competencycount = selfAssessmentService.GetCompetencyCountSelfAssessmentCertificate(candidateAssessmentId);
var accessors = selfAssessmentService.GetAccessor(competencymaindata.SelfAssessmentID, competencymaindata.LearnerId);
Expand Down
6 changes: 3 additions & 3 deletions DigitalLearningSolutions.Web/Services/SupervisorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ISupervisorService
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedSignOffs(int adminId);
IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedReviews(int adminId);
DelegateSelfAssessment? GetSelfAssessmentBaseByCandidateAssessmentId(int candidateAssessmentId);
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId);
IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId);
RoleProfile? GetRoleProfileById(int selfAssessmentId);
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesForSelfAssessment(int selfAssessmentId);
IEnumerable<SelfAssessmentSupervisorRole> GetSupervisorRolesBySelfAssessmentIdForSupervisor(int selfAssessmentId);
Expand Down Expand Up @@ -77,9 +77,9 @@ public int EnrolDelegateOnAssessment(int delegateUserId, int supervisorDelegateI
return supervisorDataService.EnrolDelegateOnAssessment(delegateUserId, supervisorDelegateId, selfAssessmentId, completeByDate, selfAssessmentSupervisorRoleId, adminId, centreId, isLoggedInUser);
}

public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId)
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int candidateId, int centreId, int? categoryId)
{
return supervisorDataService.GetAvailableRoleProfilesForDelegate(candidateId, centreId);
return supervisorDataService.GetAvailableRoleProfilesForDelegate(candidateId, centreId, categoryId);
}

public CandidateAssessmentSupervisor? GetCandidateAssessmentSupervisor(int candidateAssessmentID, int supervisorDelegateId, int selfAssessmentSupervisorRoleId)
Expand Down
Loading