diff --git a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentSupervisorDataService.cs b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentSupervisorDataService.cs index 46d3f5fd0c..5c50f08953 100644 --- a/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentSupervisorDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentSupervisorDataService.cs @@ -107,27 +107,23 @@ public IEnumerable GetOtherSupervisorsForCandidate( int candidateId ) { - const string selectQuery = + return connection.Query( @"SELECT - 0 AS ID, sd.ID AS SupervisorDelegateID, sd.SupervisorAdminID, sd.SupervisorEmail, sd.NotificationSent, - au.Forename + ' ' + au.Surname + (CASE WHEN au.Active = 1 THEN '' ELSE ' (Inactive)' END) AS SupervisorName, - 'Supervisor' AS RoleName + au.Forename + ' ' + au.Surname AS SupervisorName, + (CASE WHEN au.Supervisor = 1 THEN 'Supervisor' + WHEN au.NominatedSupervisor = 1 THEN 'Nominated supervisor' + END) AS RoleName FROM SupervisorDelegates AS sd INNER JOIN CandidateAssessmentSupervisors AS cas ON sd.ID = cas.SupervisorDelegateId INNER JOIN CandidateAssessments AS ca ON cas.CandidateAssessmentID = ca.ID - INNER JOIN AdminUsers AS au ON sd.SupervisorAdminID = au.AdminID"; - - return connection.Query( - @$"{selectQuery} - WHERE (sd.Removed IS NULL) AND (sd.SupervisorAdminID IS NOT NULL) AND (sd.CandidateID = @candidateId) - EXCEPT - {selectQuery} - WHERE (sd.Removed IS NULL) AND (sd.CandidateID = @candidateId) AND (ca.SelfAssessmentID = @selfAssessmentId) - GROUP BY sd.ID, SupervisorAdminID, SupervisorEmail, sd.NotificationSent, au.Forename + ' ' + au.Surname, au.Active", + INNER JOIN AdminUsers AS au ON sd.SupervisorAdminID = au.AdminID AND au.Active = 1 + WHERE (sd.Removed IS NULL) AND (sd.SupervisorAdminID IS NOT NULL) AND (sd.CandidateID = @candidateId) + AND (au.Supervisor = 1 OR au.NominatedSupervisor = 1) AND (au.Active = 1) + AND (ca.SelfAssessmentID <> @selfAssessmentId)", new { selfAssessmentId, candidateId } ); } @@ -236,9 +232,9 @@ int candidateId IsFrameworkDeveloper FROM AdminUsers WHERE ( - (Supervisor = 1) AND (Active = 1) AND (CategoryID = 0) AND (CentreID = @centreId) + (Supervisor = 1 OR NominatedSupervisor = 1) AND (Active = 1) AND (CategoryID = 0) AND (CentreID = @centreId) OR - (Supervisor = 1) AND (Active = 1) AND (CategoryID = (SELECT CategoryID FROM SelfAssessments WHERE (ID = @selfAssessmentId))) AND (CentreID = @centreId) + (Supervisor = 1 OR NominatedSupervisor = 1) AND (Active = 1) AND (CategoryID = (SELECT CategoryID FROM SelfAssessments WHERE (ID = @selfAssessmentId))) AND (CentreID = @centreId) ) AND AdminID NOT IN ( SELECT sd.SupervisorAdminID diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml index 0abafeec83..afaa0a6fe1 100644 --- a/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml +++ b/DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/ManageSupervisors.cshtml @@ -86,7 +86,7 @@ } @if (Model.SuggestedSupervisors.Any()) { -

Quick add

+

Quick add

Supervisors for your other activities