Skip to content

Commit 764d023

Browse files
authored
Merge pull request #3115 from TechnologyEnhancedLearning/DLS-Release-v1.1.1
Dls release v1.1.1
2 parents 17ad383 + 0bc5eab commit 764d023

File tree

50 files changed

+790
-682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+790
-682
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+

2+
namespace DigitalLearningSolutions.Data.Migrations
3+
{
4+
using FluentMigrator;
5+
6+
[Migration(202410071401)]
7+
public class UpdateCandidateAssessmentSupervisorsTabl : ForwardOnlyMigration
8+
{
9+
public override void Up()
10+
{
11+
Execute.Sql($@"UPDATE cas
12+
SET SelfAssessmentSupervisorRoleID = (SELECT ID FROM SelfAssessmentSupervisorRoles
13+
WHERE SelfAssessmentID = ssr.SelfAssessmentID and AllowDelegateNomination = 1)
14+
FROM CandidateAssessmentSupervisors cas INNER JOIN
15+
SelfAssessmentSupervisorRoles ssr ON cas.SelfAssessmentSupervisorRoleID = ssr.ID
16+
AND cas.Removed IS NULL AND ssr.AllowDelegateNomination = 0 INNER JOIN
17+
SupervisorDelegates sd ON cas.SupervisorDelegateId = sd.ID INNER JOIN
18+
AdminAccounts aa ON sd.SupervisorAdminID = aa.ID WHERE aa.IsSupervisor = 0 AND aa.IsNominatedSupervisor = 1");
19+
}
20+
}
21+
}

DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,13 @@
469469
<data name="TD_4950_Alter_GetAssessmentResultsByDelegate_UP" type="System.Resources.ResXFileRef, System.Windows.Forms">
470470
<value>..\Scripts\TD_4950_Alter_GetAssessmentResultsByDelegate_UP.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
471471
</data>
472+
<data name="TD-4950-dboGetOtherCentresForSelfAssessmentCreateOrAlter" type="System.Resources.ResXFileRef, System.Windows.Forms">
473+
<value>..\Resources\TD-4950-dboGetOtherCentresForSelfAssessmentCreateOrAlter.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
474+
</data>
475+
<data name="TD_4878_Alter_GetActivitiesForDelegateEnrolment_Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
476+
<value>..\Scripts\TD-4878-Alter_GetActivitiesForDelegateEnrolment_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
477+
</data>
478+
<data name="TD_4878_Alter_GetActivitiesForDelegateEnrolment_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
479+
<value>..\Scripts\TD-4878-Alter_GetActivitiesForDelegateEnrolment_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
480+
</data>
472481
</root>

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int sup
139139
public IEnumerable<DelegateAssessmentStatistics> GetDelegateAssessmentStatisticsAtCentre(string searchString, int centreId, string categoryName, string isActive, int? categoryId);
140140

141141
bool IsSelfEnrollmentAllowed(int customisationId);
142-
Customisation? GetCourse(int customisationId);
142+
Customisation? GetCourse(int? customisationId);
143143
}
144144

145145
public class CourseDataService : ICourseDataService
@@ -537,16 +537,16 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
537537
if (candidateAssessmentId > 1 && supervisorDelegateId == 0)
538538
{
539539
connection.Execute(
540-
@"UPDATE CandidateAssessments SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId, CompleteByDate = @completeByDateDynamic
540+
@"UPDATE CandidateAssessments SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId, CompleteByDate = @completeByDateDynamic, EnrolledByAdminId = @enrolledByAdminId
541541
WHERE ID = @candidateAssessmentId",
542-
new { candidateAssessmentId, enrolmentMethodId, completeByDateDynamic }
542+
new { candidateAssessmentId, enrolmentMethodId, completeByDateDynamic, enrolledByAdminId }
543543
);
544544
}
545545
if (candidateAssessmentId > 1 && supervisorDelegateId != 0)
546546
{
547547
string sqlQuery = $@"
548548
BEGIN TRANSACTION
549-
UPDATE CandidateAssessments SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId, CompleteByDate = @completeByDateDynamic
549+
UPDATE CandidateAssessments SET RemovedDate = NULL, EnrolmentMethodId = @enrolmentMethodId, CompleteByDate = @completeByDateDynamic, EnrolledByAdminId = @enrolledByAdminId
550550
WHERE ID = @candidateAssessmentId
551551
552552
UPDATE CandidateAssessmentSupervisors SET Removed = NULL
@@ -556,7 +556,7 @@ BEGIN TRANSACTION
556556
COMMIT TRANSACTION";
557557

558558
connection.Execute(sqlQuery
559-
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId, completeByDateDynamic, supervisorDelegateId });
559+
, new { candidateAssessmentId, selfAssessmentSupervisorRoleId, enrolmentMethodId, completeByDateDynamic, supervisorDelegateId, enrolledByAdminId });
560560
}
561561

562562
if (supervisorId > 0)
@@ -2024,7 +2024,7 @@ public bool IsSelfEnrollmentAllowed(int customisationId)
20242024
return selfRegister > 0;
20252025
}
20262026

2027-
public Customisation? GetCourse(int customisationId)
2027+
public Customisation? GetCourse(int? customisationId)
20282028
{
20292029
return connection.Query<Customisation>(
20302030
@"SELECT CustomisationID

DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool zeroBased
130130

131131
int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId);
132132

133-
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify);
133+
int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID);
134134
void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass);
135135
void UpdateFrameworkCustomFlag(int frameworkId, int id, string flagName, string flagGroup, string flagTagClass);
136136

@@ -299,7 +299,7 @@ FROM CourseTopics
299299

300300
private const string FrameworkTables =
301301
@"Frameworks AS FW LEFT OUTER JOIN
302-
FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId
302+
FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId AND COALESCE(IsDeleted, 0) = 0
303303
LEFT OUTER JOIN FrameworkReviews AS fwr ON fwc.ID = fwr.FrameworkCollaboratorID AND fwr.Archived IS NULL AND fwr.ReviewComplete IS NULL";
304304

305305
private const string AssessmentQuestionFields =
@@ -751,7 +751,7 @@ FROM FrameworkCollaborators fc
751751
);
752752
}
753753

754-
public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool canModify)
754+
public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool canModify, int? centreID)
755755
{
756756
if (userEmail is null || userEmail.Length == 0)
757757
{
@@ -774,8 +774,8 @@ FROM FrameworkCollaborators
774774
}
775775

776776
var adminId = (int?)connection.ExecuteScalar(
777-
@"SELECT AdminID FROM AdminUsers WHERE Email = @userEmail AND Active = 1",
778-
new { userEmail }
777+
@"SELECT AdminID FROM AdminUsers WHERE Email = @userEmail AND Active = 1 AND CentreID = @centreID",
778+
new { userEmail, centreID }
779779
);
780780
if (adminId is null)
781781
{
@@ -1823,11 +1823,11 @@ FROM Competencies AS C INNER JOIN
18231823

18241824
public int GetAdminUserRoleForFrameworkId(int adminId, int frameworkId)
18251825
{
1826-
return (int)connection.ExecuteScalar(
1827-
@"SELECT CASE WHEN FW.OwnerAdminID = @adminId THEN 3 WHEN fwc.CanModify = 1 THEN 2 WHEN fwc.CanModify = 0 THEN 1 ELSE 0 END AS UserRole
1828-
FROM Frameworks AS FW LEFT OUTER JOIN
1829-
FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId
1830-
WHERE FW.ID = @frameworkId",
1826+
return connection.QuerySingle<int>(
1827+
@"SELECT CASE WHEN FW.OwnerAdminID = @adminId THEN 3 WHEN COALESCE (fwc.CanModify, 0) = 1 THEN 2 WHEN COALESCE (fwc.CanModify, 0) = 0 THEN 1 ELSE 0 END AS UserRole
1828+
FROM Frameworks AS FW LEFT OUTER JOIN
1829+
FrameworkCollaborators AS fwc ON fwc.FrameworkID = FW.ID AND fwc.AdminID = @adminId AND fwc.IsDeleted = 0
1830+
WHERE (FW.ID = @frameworkId)",
18311831
new { adminId, frameworkId }
18321832
);
18331833
}

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CompetencyDataService.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,41 @@ FROM SelfAssessmentResults
615615
);
616616
}
617617

618+
public IEnumerable<SelfAssessmentResult> GetSelfAssessmentResultswithSupervisorVerificationsForDelegateSelfAssessmentCompetency(
619+
int delegateUserId,
620+
int selfAssessmentId,
621+
int competencyId
622+
)
623+
{
624+
return connection.Query<SelfAssessmentResult>(
625+
@"SELECT
626+
s.ID,
627+
s.SelfAssessmentID,
628+
s.CompetencyID,
629+
s.AssessmentQuestionID,
630+
s.Result,
631+
s.DateTime,
632+
s.SupportingComments,
633+
s.DelegateUserId
634+
FROM SelfAssessmentResults s inner join
635+
SelfAssessmentResultSupervisorVerifications sv ON s.ID = sv.SelfAssessmentResultId AND sv.Superceded = 0
636+
WHERE s.CompetencyID = @competencyId
637+
AND s.SelfAssessmentID = @selfAssessmentId
638+
AND s.DelegateUserID = @delegateUserId",
639+
new { selfAssessmentId, delegateUserId, competencyId }
640+
);
641+
}
642+
643+
public void RemoveReviewCandidateAssessmentOptionalCompetencies(int id)
644+
{
645+
646+
connection.Execute(@"UPDATE SelfAssessmentResults SET Result = NULL WHERE ID = @id", new { id});
647+
648+
connection.Execute(
649+
@"delete from SelfAssessmentResultSupervisorVerifications WHERE SelfAssessmentResultId = @id", new { id });
650+
651+
}
652+
618653
private static string PrintResult(
619654
int competencyId,
620655
int selfAssessmentId,

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ int GetSelfAssessmentActivityDelegatesExportCount(string searchString, string so
173173
bool IsCentreSelfAssessment(int selfAssessmentId, int centreId);
174174
bool HasMinimumOptionalCompetencies(int selfAssessmentId, int delegateUserId);
175175
int GetSelfAssessmentCategoryId(int selfAssessmentId);
176+
void RemoveReviewCandidateAssessmentOptionalCompetencies(int id);
177+
public IEnumerable<SelfAssessmentResult> GetSelfAssessmentResultswithSupervisorVerificationsForDelegateSelfAssessmentCompetency(
178+
int delegateUserId,
179+
int selfAssessmentId,
180+
int competencyId
181+
);
176182
}
177183
public partial class SelfAssessmentDataService : ISelfAssessmentDataService
178184
{

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentSupervisorDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int delegateUserId
7878
return connection.Query<SelfAssessmentSupervisor>(
7979
@$"{SelectSelfAssessmentSupervisorQuery}
8080
WHERE (sd.Removed IS NULL) AND (cas.Removed IS NULL) AND (ca.DelegateUserID = @delegateUserId)
81-
AND (ca.SelfAssessmentID = @selfAssessmentId)
81+
AND (ca.SelfAssessmentID = @selfAssessmentId) AND (au.Supervisor = 1 or au.NominatedSupervisor = 1)
8282
AND (au.CategoryID = 0 OR au.CategoryID IN (select CategoryID from SelfAssessments where ID = @selfAssessmentId))
8383
ORDER BY SupervisorName",
8484
new { selfAssessmentId, delegateUserId }
@@ -95,7 +95,7 @@ int delegateUserId
9595
WHERE (sd.Removed IS NULL) AND (cas.Removed IS NULL) AND (sd.DelegateUserID = @delegateUserId)
9696
AND (ca.SelfAssessmentID = @selfAssessmentId) AND (sd.SupervisorAdminID IS NOT NULL)
9797
AND (coalesce(sasr.ResultsReview, 1) = 1)
98-
AND au.Active = 1
98+
AND au.Active = 1 AND (au.Supervisor = 1 or au.NominatedSupervisor = 1)
9999
AND (au.CategoryID = 0 OR au.CategoryID IN (select CategoryID from SelfAssessments where ID = @selfAssessmentId))
100100
ORDER BY SupervisorName",
101101
new { selfAssessmentId, delegateUserId }
@@ -153,7 +153,7 @@ int delegateUserId
153153
WHERE (sd.Removed IS NULL) AND (cas.Removed IS NULL) AND (sd.DelegateUserID = @delegateUserId) AND (ca.SelfAssessmentID = @selfAssessmentId)
154154
AND (sd.SupervisorAdminID IS NOT NULL) AND (coalesce(sasr.SelfAssessmentReview, 1) = 1)
155155
AND (cas.ID NOT IN (SELECT CandidateAssessmentSupervisorID FROM CandidateAssessmentSupervisorVerifications WHERE Verified IS NULL))
156-
AND au.Active = 1
156+
AND au.Active = 1 AND (au.Supervisor = 1 or au.NominatedSupervisor = 1)
157157
AND (au.CategoryID = 0 OR au.CategoryID IN (select CategoryID from SelfAssessments where ID = @selfAssessmentId))
158158
ORDER BY SupervisorName",
159159
new { selfAssessmentId, delegateUserId }

DigitalLearningSolutions.Data/DataServices/SupervisorDataService.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,35 @@ public SupervisorDataService(IDbConnection connection, ILogger<SupervisorDataSer
126126
public DashboardData? GetDashboardDataForAdminId(int adminId)
127127
{
128128
return connection.Query<DashboardData>(
129-
@" SELECT (SELECT COUNT(sd.ID) AS StaffCount
130-
FROM SupervisorDelegates sd
131-
LEFT OUTER JOIN users u
132-
ON u.id = sd.DelegateUserID
133-
AND u.Active = 1
134-
WHERE (sd.SupervisorAdminID = @adminId)
135-
AND (sd.Removed IS NULL)) AS StaffCount,
129+
@"SELECT (SELECT COUNT(sd.ID) AS StaffCount
130+
FROM CustomPrompts AS cp6
131+
RIGHT OUTER JOIN CustomPrompts AS cp5
132+
RIGHT OUTER JOIN DelegateAccounts AS da
133+
RIGHT OUTER JOIN SupervisorDelegates AS sd
134+
INNER JOIN AdminUsers AS au
135+
ON sd.SupervisorAdminID = au.AdminID
136+
INNER JOIN Centres AS ct
137+
ON au.CentreID = ct.CentreID
138+
ON da.CentreID = ct.CentreID
139+
AND da.UserID = sd.DelegateUserID
140+
LEFT OUTER JOIN Users AS u
141+
LEFT OUTER JOIN JobGroups AS jg
142+
ON u.JobGroupID = jg.JobGroupID
143+
ON da.UserID = u.ID
144+
LEFT OUTER JOIN CustomPrompts AS cp1
145+
ON ct.CustomField1PromptID = cp1.CustomPromptID
146+
LEFT OUTER JOIN CustomPrompts AS cp2
147+
ON ct.CustomField2PromptID = cp2.CustomPromptID
148+
LEFT OUTER JOIN CustomPrompts AS cp3
149+
ON ct.CustomField3PromptID = cp3.CustomPromptID
150+
LEFT OUTER JOIN CustomPrompts AS cp4
151+
ON ct.CustomField4PromptID = cp4.CustomPromptID
152+
ON cp5.CustomPromptID = ct.CustomField5PromptID
153+
ON cp6.CustomPromptID = ct.CustomField6PromptID
154+
LEFT OUTER JOIN AdminAccounts AS au2
155+
ON da.UserID = au2.UserID AND da.CentreID = au2.CentreID
156+
WHERE (sd.SupervisorAdminID = @adminId) AND (sd.Removed IS NULL) AND
157+
(u.ID = da.UserID OR sd.DelegateUserID IS NULL)) AS StaffCount,
136158
(SELECT COUNT(ID) AS StaffCount
137159
FROM SupervisorDelegates AS SupervisorDelegates_1
138160
WHERE (SupervisorAdminID = @adminId)

0 commit comments

Comments
 (0)