Skip to content

Commit 15ddc25

Browse files
authored
Merge pull request #2505 from TechnologyEnhancedLearning/Release-2023.23-Hotfix
Release 2023.23 hotfix
2 parents 21ac8c6 + ff3c4f0 commit 15ddc25

File tree

59 files changed

+320
-175
lines changed

Some content is hidden

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

59 files changed

+320
-175
lines changed

DigitalLearningSolutions.Data/DataServices/CourseContentService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ public void UpdateProgress(int progressId)
240240
var numberOfAffectedRows = connection.Execute(
241241
@"UPDATE Progress
242242
SET LoginCount = (SELECT COALESCE(COUNT(*), 0)
243-
FROM Sessions AS S
243+
FROM Sessions AS S WITH (NOLOCK)
244244
WHERE S.CandidateID = Progress.CandidateID
245245
AND S.CustomisationID = Progress.CustomisationID
246246
AND S.LoginTime >= Progress.FirstSubmittedTime),
247247
Duration = (SELECT COALESCE(SUM(S1.Duration), 0)
248-
FROM Sessions AS S1
248+
FROM Sessions AS S1 WITH (NOLOCK)
249249
WHERE S1.CandidateID = Progress.CandidateID
250250
AND S1.CustomisationID = Progress.CustomisationID
251251
AND S1.LoginTime >= Progress.FirstSubmittedTime),

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,13 +1097,13 @@ AND ap.DefaultContentTypeID <> 4
10971097
AND ((@hasCompleted IS NULL) OR (@hasCompleted = 1 AND pr.Completed IS NOT NULL) OR (@hasCompleted = 0 AND pr.Completed IS NULL))
10981098
10991099
AND ((@answer1 IS NULL) OR ((@answer1 = 'No option selected' OR @answer1 = 'FREETEXTBLANKVALUE') AND (pr.Answer1 IS NULL OR LTRIM(RTRIM(pr.Answer1)) = ''))
1100-
OR (@answer1 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer1 IS NOT NULL OR pr.Answer1 = @answer1)))
1100+
OR ((@answer1 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer1 IS NOT NULL AND LTRIM(RTRIM(pr.Answer1)) != '') OR (pr.Answer1 IS NOT NULL AND pr.Answer1 = @answer1)))
11011101
11021102
AND ((@answer2 IS NULL) OR ((@answer2 = 'No option selected' OR @answer2 = 'FREETEXTBLANKVALUE') AND (pr.Answer2 IS NULL OR LTRIM(RTRIM(pr.Answer2)) = ''))
1103-
OR (@answer2 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer2 IS NOT NULL OR pr.Answer2 = @answer2)))
1103+
OR ((@answer2 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer2 IS NOT NULL AND LTRIM(RTRIM(pr.Answer2)) != '') OR (pr.Answer2 IS NOT NULL AND pr.Answer2 = @answer2)))
11041104
11051105
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
1106-
OR (@answer3 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer3 IS NOT NULL OR pr.Answer3 = @answer3)))
1106+
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
11071107
11081108
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
11091109

@@ -1639,13 +1639,13 @@ AND ap.DefaultContentTypeID <> 4
16391639
AND ((@hasCompleted IS NULL) OR (@hasCompleted = 1 AND pr.Completed IS NOT NULL) OR (@hasCompleted = 0 AND pr.Completed IS NULL))
16401640
16411641
AND ((@answer1 IS NULL) OR ((@answer1 = 'No option selected' OR @answer1 = 'FREETEXTBLANKVALUE') AND (pr.Answer1 IS NULL OR LTRIM(RTRIM(pr.Answer1)) = ''))
1642-
OR (@answer1 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer1 IS NOT NULL OR pr.Answer1 = @answer1)))
1642+
OR ((@answer1 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer1 IS NOT NULL AND LTRIM(RTRIM(pr.Answer1)) != '') OR (pr.Answer1 IS NOT NULL AND pr.Answer1 = @answer1)))
16431643
16441644
AND ((@answer2 IS NULL) OR ((@answer2 = 'No option selected' OR @answer2 = 'FREETEXTBLANKVALUE') AND (pr.Answer2 IS NULL OR LTRIM(RTRIM(pr.Answer2)) = ''))
1645-
OR (@answer2 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer2 IS NOT NULL OR pr.Answer2 = @answer2)))
1645+
OR ((@answer2 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer2 IS NOT NULL AND LTRIM(RTRIM(pr.Answer2)) != '') OR (pr.Answer2 IS NOT NULL AND pr.Answer2 = @answer2)))
16461646
16471647
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
1648-
OR (@answer3 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer3 IS NOT NULL OR pr.Answer3 = @answer3)))
1648+
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
16491649
16501650
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
16511651

@@ -1740,13 +1740,13 @@ AND ap.DefaultContentTypeID <> 4
17401740
AND ((@hasCompleted IS NULL) OR (@hasCompleted = 1 AND pr.Completed IS NOT NULL) OR (@hasCompleted = 0 AND pr.Completed IS NULL))
17411741
17421742
AND ((@answer1 IS NULL) OR ((@answer1 = 'No option selected' OR @answer1 = 'FREETEXTBLANKVALUE') AND (pr.Answer1 IS NULL OR LTRIM(RTRIM(pr.Answer1)) = ''))
1743-
OR (@answer1 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer1 IS NOT NULL OR pr.Answer1 = @answer1)))
1743+
OR ((@answer1 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer1 IS NOT NULL AND LTRIM(RTRIM(pr.Answer1)) != '') OR (pr.Answer1 IS NOT NULL AND pr.Answer1 = @answer1)))
17441744
17451745
AND ((@answer2 IS NULL) OR ((@answer2 = 'No option selected' OR @answer2 = 'FREETEXTBLANKVALUE') AND (pr.Answer2 IS NULL OR LTRIM(RTRIM(pr.Answer2)) = ''))
1746-
OR (@answer2 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer2 IS NOT NULL OR pr.Answer2 = @answer2)))
1746+
OR ((@answer2 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer2 IS NOT NULL AND LTRIM(RTRIM(pr.Answer2)) != '') OR (pr.Answer2 IS NOT NULL AND pr.Answer2 = @answer2)))
17471747
17481748
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
1749-
OR (@answer3 = 'FREETEXTNOTBLANKVALUE' AND (pr.Answer3 IS NOT NULL OR pr.Answer3 = @answer3)))
1749+
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
17501750
17511751
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
17521752

DigitalLearningSolutions.Data/DataServices/SessionDataService.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface ISessionDataService
1111

1212
void StopDelegateSession(int candidateId);
1313

14-
void UpdateDelegateSessionDuration(int sessionId, DateTime currentUtcTime);
14+
int UpdateDelegateSessionDuration(int sessionId, DateTime currentUtcTime);
1515

1616
int StartAdminSession(int adminId);
1717

@@ -55,9 +55,9 @@ public void StopDelegateSession(int candidateId)
5555
connection.Query(StopSessionsSql, new { candidateId });
5656
}
5757

58-
public void UpdateDelegateSessionDuration(int sessionId, DateTime currentUtcTime)
58+
public int UpdateDelegateSessionDuration(int sessionId, DateTime currentUtcTime)
5959
{
60-
connection.Query(
60+
return connection.Execute(
6161
@"UPDATE Sessions SET Duration = DATEDIFF(minute, LoginTime, @currentUtcTime)
6262
WHERE [SessionID] = @sessionId AND Active = 1;",
6363
new { sessionId, currentUtcTime }
@@ -85,19 +85,19 @@ public bool HasAdminGotSessions(int adminId)
8585
public bool HasAdminGotReferences(int adminId)
8686
{
8787
return connection.ExecuteScalar<bool>(
88-
@"SELECT TOP 1 AdminSessions.AdminID FROM AdminSessions WHERE AdminSessions.AdminID = @adminId
88+
@"SELECT TOP 1 AdminSessions.AdminID FROM AdminSessions WITH (NOLOCK) WHERE AdminSessions.AdminID = @adminId
8989
UNION ALL
90-
SELECT TOP 1 FrameworkCollaborators.AdminID FROM FrameworkCollaborators WHERE FrameworkCollaborators.AdminID = @adminId
90+
SELECT TOP 1 FrameworkCollaborators.AdminID FROM FrameworkCollaborators WITH (NOLOCK) WHERE FrameworkCollaborators.AdminID = @adminId
9191
UNION ALL
92-
SELECT TOP 1 SupervisorDelegates.SupervisorAdminID FROM SupervisorDelegates WHERE SupervisorDelegates.SupervisorAdminID = @adminId",
92+
SELECT TOP 1 SupervisorDelegates.SupervisorAdminID FROM SupervisorDelegates WITH (NOLOCK) WHERE SupervisorDelegates.SupervisorAdminID = @adminId",
9393
new { adminId }
9494
);
9595
}
9696

9797
public bool HasDelegateGotSessions(int delegateId)
9898
{
9999
return connection.ExecuteScalar<bool>(
100-
"SELECT 1 WHERE EXISTS (SELECT CandidateID FROM Sessions WHERE CandidateID = @delegateId)",
100+
"SELECT 1 WHERE EXISTS (SELECT CandidateID FROM Sessions WITH (NOLOCK) WHERE CandidateID = @delegateId)",
101101
new { delegateId }
102102
);
103103
}
@@ -111,7 +111,7 @@ public bool HasDelegateGotSessions(int delegateId)
111111
LoginTime,
112112
Duration,
113113
Active
114-
FROM Sessions WHERE SessionID = @sessionId",
114+
FROM Sessions WITH (NOLOCK) WHERE SessionID = @sessionId",
115115
new { sessionId }
116116
);
117117
}

DigitalLearningSolutions.Data/DataServices/SupervisorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ LEFT JOIN UserCentreDetails ucd
11391139
@"
11401140
SELECT ID
11411141
FROM SupervisorDelegates sd
1142-
WHERE (sd.SupervisorAdminID = @supervisorAdminID OR @supervisorAdminID = 0) AND (sd.DelegateUserID = @delegateUserId OR @delegateUserID = 0 OR DelegateEmail = @delegateEmail)
1142+
WHERE (sd.SupervisorAdminID = @supervisorAdminID OR @supervisorAdminID = 0) AND (sd.DelegateUserID = @delegateUserId OR @delegateUserID = 0) AND DelegateEmail = @delegateEmail
11431143
ORDER BY ID DESC
11441144
",
11451145
new

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/CompletionSummaryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void CourseCompletion_should_UpdateProgress_if_valid_course()
8888
controller.CompletionSummary(CustomisationId);
8989

9090
// Then
91-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
91+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A<int>._, A<int>._, A<ISession>._)).MustHaveHappened();
9292
A.CallTo(() => courseContentService.UpdateProgress(A<int>._))
9393
.WhenArgumentsMatch((int id) => id != progressId)
9494
.MustNotHaveHappened();

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/DiagnosticAssessmentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Diagnostic_assessment_should_UpdateProgress_if_valid_diagnostic_asse
7878
controller.Diagnostic(CustomisationId, SectionId);
7979

8080
// Then
81-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
81+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A<int>._, A<int>._, A<ISession>._)).MustHaveHappened();
8282
}
8383

8484
[Test]

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/DiagnosticContentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void Diagnostic_content_should_UpdateProgress_if_valid_diagnostic_content
8383
controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials);
8484

8585
// Then
86-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
86+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A<int>._, A<int>._, A<ISession>._)).MustHaveHappened();
8787
}
8888

8989
[Test]

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/IndexTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void Index_valid_customisation_id_should_update_login_and_duration()
147147
controller.Index(CustomisationId);
148148

149149
// Then
150-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
150+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(CandidateId, CustomisationId, A<ISession>._)).MustHaveHappened();
151151
}
152152

153153
[Test]

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/PostLearningAssessmentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Post_learning_assessment_should_UpdateProgress_if_valid_post_learnin
7878
controller.PostLearning(CustomisationId, SectionId);
7979

8080
// Then
81-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
81+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A<int>._, A<int>._, A<ISession>._)).MustHaveHappened();
8282
}
8383

8484
[Test]

DigitalLearningSolutions.Web.Tests/Controllers/LearningMenu/PostLearningContentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Post_learning_content_should_UpdateProgress_if_valid_post_learning_c
7878
controller.PostLearningContent(CustomisationId, SectionId);
7979

8080
// Then
81-
A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened();
81+
A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A<int>._, A<int>._, A<ISession>._)).MustHaveHappened();
8282
}
8383

8484
[Test]

0 commit comments

Comments
 (0)