Skip to content

Commit 82e5631

Browse files
Merge branch 'DLS-Release-v1.1.0' into Develop/Features/TD-4881-LimitthesupervisorMyStaffviewselfassessmentcountstoincludeonlythoseintheirassignedcategory
2 parents 1e49356 + df38a7c commit 82e5631

File tree

18 files changed

+303
-134
lines changed

18 files changed

+303
-134
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+

2+
3+
namespace DigitalLearningSolutions.Data.Migrations
4+
{
5+
using FluentMigrator;
6+
7+
[Migration(202410231405)]
8+
public class Alter_GetActivitiesForDelegateEnrolment : Migration
9+
{
10+
public override void Up()
11+
{
12+
Execute.Sql(Properties.Resources.TD_4878_Alter_GetActivitiesForDelegateEnrolment_Up);
13+
}
14+
public override void Down()
15+
{
16+
Execute.Sql(Properties.Resources.TD_4878_Alter_GetActivitiesForDelegateEnrolment_Down);
17+
}
18+
}
19+
}

DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,10 @@
448448
<data name="TD_4634_Alter_GetCompletedCoursesForCandidate_UP" type="System.Resources.ResXFileRef, System.Windows.Forms">
449449
<value>..\Scripts\TD_4634_Alter_GetCompletedCoursesForCandidate_UP.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
450450
</data>
451+
<data name="TD_4878_Alter_GetActivitiesForDelegateEnrolment_Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
452+
<value>..\Scripts\TD-4878-Alter_GetActivitiesForDelegateEnrolment_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
453+
</data>
454+
<data name="TD_4878_Alter_GetActivitiesForDelegateEnrolment_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
455+
<value>..\Scripts\TD-4878-Alter_GetActivitiesForDelegateEnrolment_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
456+
</data>
451457
</root>

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
541541
new { candidateAssessmentId, enrolmentMethodId, completeByDateDynamic }
542542
);
543543
}
544-
if (candidateAssessmentId > 1 && supervisorDelegateId !=0)
544+
545+
if (candidateAssessmentId > 1 && supervisorDelegateId !=0)
546+
545547
{
546548
string sqlQuery = $@"
547549
BEGIN TRANSACTION
@@ -558,6 +560,23 @@ BEGIN TRANSACTION
558560
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId, completeByDateDynamic });
559561
}
560562

563+
if (supervisorId > 0)
564+
{
565+
566+
var adminUserId = Convert.ToInt32(connection.ExecuteScalar(@"SELECT UserID FROM AdminAccounts WHERE (AdminAccounts.ID = @supervisorId)",
567+
new { supervisorId })
568+
);
569+
570+
if (delegateUserId == adminUserId)
571+
{
572+
connection.Execute(
573+
@"UPDATE CandidateAssessments SET NonReportable = 1 WHERE ID = @candidateAssessmentId",
574+
new { candidateAssessmentId }
575+
);
576+
577+
}
578+
}
579+
561580
if (candidateAssessmentId < 1)
562581
{
563582
logger.LogWarning(

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,21 @@ FROM SelfAssessments
229229
sa.SupervisorSelfAssessmentReview,
230230
sa.SupervisorResultsReview";
231231

232-
var fromTableQuery = $@" FROM dbo.SelfAssessments AS sa
232+
var fromTableQuery = $@" FROM dbo.SelfAssessments AS sa
233233
INNER JOIN dbo.CandidateAssessments AS ca WITH (NOLOCK) ON sa.ID = ca.SelfAssessmentID
234234
INNER JOIN dbo.CentreSelfAssessments AS csa WITH (NOLOCK) ON sa.ID = csa.SelfAssessmentID
235235
INNER JOIN dbo.DelegateAccounts da WITH (NOLOCK) ON ca.CentreID = da.CentreID AND ca.DelegateUserID = da.UserID AND da.CentreID = csa.CentreID
236236
INNER JOIN dbo.Users u WITH (NOLOCK) ON DA.UserID = u.ID
237237
LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND ucd.centreID = da.CentreID
238-
LEFT OUTER JOIN AdminAccounts AS aaEnrolledBy WITH (NOLOCK) ON aaEnrolledBy.ID = ca.EnrolledByAdminID
238+
LEFT OUTER JOIN AdminAccounts AS aaEnrolledBy WITH (NOLOCK) ON aaEnrolledBy.ID = ca.EnrolledByAdminID
239239
LEFT OUTER JOIN Users AS uEnrolledBy WITH (NOLOCK) ON uEnrolledBy.ID = aaEnrolledBy.UserID
240240
LEFT JOIN dbo.CandidateAssessmentSupervisors AS cas WITH (NOLOCK) ON ca.ID = cas.CandidateAssessmentID
241241
LEFT JOIN dbo.CandidateAssessmentSupervisorVerifications AS casv WITH (NOLOCK) ON cas.ID = casv.CandidateAssessmentSupervisorID AND
242242
(casv.Verified IS NOT NULL AND casv.SignedOff = 1)
243243
244244
WHERE sa.ID = @selfAssessmentId
245245
AND da.CentreID = @centreID AND csa.CentreID = @centreID
246-
AND (ca.RemovedDate IS NULL)
246+
AND (ca.RemovedDate IS NULL) AND ( aaEnrolledBy.CategoryID IS NULL OR sa.CategoryID = aaEnrolledBy.CategoryID)
247247
AND ( u.FirstName + ' ' + u.LastName + ' ' + COALESCE(ucd.Email, u.PrimaryEmail) + ' ' + COALESCE(da.CandidateNumber, '') LIKE N'%' + @searchString + N'%')
248248
AND ((@isDelegateActive IS NULL) OR (@isDelegateActive = 1 AND (da.Active = 1)) OR (@isDelegateActive = 0 AND (da.Active = 0)))
249249
AND ((@removed IS NULL) OR (@removed = 1 AND (ca.RemovedDate IS NOT NULL)) OR (@removed = 0 AND (ca.RemovedDate IS NULL)))

DigitalLearningSolutions.Data/DataServices/SupervisorDataService.cs

Lines changed: 10 additions & 11 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);
@@ -35,7 +35,7 @@ public interface ISupervisorDataService
3535
CandidateAssessmentSupervisor? GetCandidateAssessmentSupervisor(int candidateAssessmentID, int supervisorDelegateId, int selfAssessmentSupervisorRoleId);
3636
SelfAssessmentResultSummary? GetSelfAssessmentResultSummary(int candidateAssessmentId, int supervisorDelegateId);
3737
IEnumerable<CandidateAssessmentSupervisorVerificationSummary> GetCandidateAssessmentSupervisorVerificationSummaries(int candidateAssessmentId);
38-
IEnumerable<SupervisorForEnrolDelegate> GetSupervisorForEnrolDelegate(int CustomisationID, int CentreID);
38+
IEnumerable<SupervisorForEnrolDelegate> GetSupervisorForEnrolDelegate(int CentreID, int CategoryID);
3939
//UPDATE DATA
4040
bool ConfirmSupervisorDelegateById(int supervisorDelegateId, int candidateId, int adminId);
4141
bool RemoveSupervisorDelegateById(int supervisorDelegateId, int delegateUserId, int adminId);
@@ -382,7 +382,7 @@ LEFT JOIN UserCentreDetails ucd
382382
}
383383
}
384384

385-
public IEnumerable<SupervisorForEnrolDelegate> GetSupervisorForEnrolDelegate(int CustomisationID, int CentreID)
385+
public IEnumerable<SupervisorForEnrolDelegate> GetSupervisorForEnrolDelegate(int CentreID, int CategoryID)
386386
{
387387
return connection.Query<SupervisorForEnrolDelegate>(
388388
$@"SELECT aa.ID AS AdminID,
@@ -393,14 +393,11 @@ FROM AdminAccounts AS aa INNER JOIN
393393
Centres AS c ON aa.CentreID = c.CentreID LEFT OUTER JOIN
394394
UserCentreDetails AS ucd ON u.ID = ucd.UserID AND c.CentreID = ucd.CentreID
395395
WHERE (aa.IsSupervisor = 1) AND (c.CentreID = @CentreID) AND
396-
(ISNULL(aa.CategoryID, 0) = 0 OR CategoryID =
397-
(SELECT aa.CategoryID FROM Applications AS a INNER JOIN
398-
Customisations AS c ON a.ApplicationID = c.ApplicationID
399-
WHERE (c.CustomisationID = @CustomisationID))) AND
396+
(ISNULL(aa.CategoryID, 0) = 0 OR aa.CategoryID = @CategoryID) AND
400397
(aa.Active = 1)
401398
GROUP BY aa.ID, u.LastName, u.FirstName, COALESCE(ucd.Email, u.PrimaryEmail), CentreName
402399
ORDER BY u.FirstName, u.LastName",
403-
new { CentreID, CustomisationID });
400+
new { CentreID, CategoryID });
404401
}
405402

406403
public bool ConfirmSupervisorDelegateById(int supervisorDelegateId, int delegateUserId, int adminId)
@@ -638,7 +635,7 @@ public int RemoveSelfAssessmentResultSupervisorVerificationById(int id)
638635
}
639636
return numberOfAffectedRows;
640637
}
641-
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId)
638+
public IEnumerable<RoleProfile> GetAvailableRoleProfilesForDelegate(int delegateUserId, int centreId, int? categoryId)
642639
{
643640
return connection.Query<RoleProfile>(
644641
$@"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,
@@ -659,8 +656,10 @@ FROM SelfAssessments AS rp INNER JOIN
659656
WHERE (rp.ArchivedDate IS NULL) AND (rp.ID NOT IN
660657
(SELECT SelfAssessmentID
661658
FROM CandidateAssessments AS CA
662-
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL) AND (CompletedDate IS NULL))) AND ((rp.SupervisorSelfAssessmentReview = 1) OR
663-
(rp.SupervisorResultsReview = 1))", new { delegateUserId, centreId }
659+
WHERE (DelegateUserID = @delegateUserId) AND (RemovedDate IS NULL)
660+
AND (CompletedDate IS NULL)))
661+
AND ((rp.SupervisorSelfAssessmentReview = 1) OR (rp.SupervisorResultsReview = 1))
662+
AND (ISNULL(@categoryId, 0) = 0 OR rp.CategoryID = @categoryId)", new { delegateUserId, centreId, categoryId }
664663
);
665664
}
666665

DigitalLearningSolutions.Data/Models/Courses/AvailableCourse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public string? Topic
1717
}
1818
public int DelegateStatus { get; set; }
1919
public bool HideInLearnerPortal { get; set; }
20+
public int CategoryID { get; set; }
2021

2122
private string? category;
2223
private string? topic;

DigitalLearningSolutions.Data/Models/SessionData/Tracking/Delegate/Enrol/SessionEnrolDelegate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public class SessionEnrolDelegate
1616
public string? SupervisorEmail { get; set; }
1717
public bool IsSelfAssessment { get; set; }
1818
public int AssessmentVersion { get; set; }
19+
public int? AssessmentCategoryID { get; set; }
1920
}
2021
}

0 commit comments

Comments
 (0)