Skip to content

Commit 1a0a665

Browse files
TD-1325: My Learning record disappearing after session completed
1 parent 4a2ce59 commit 1a0a665

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

LearningHub.Nhs.WebUI/Controllers/Api/ScormController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ private async Task<bool> Commit(SCO scoObject)
260260

261261
// Persist update.
262262
await this.activityService.UpdateScormActivityAsync(scoObject);
263+
if (scoObject.LessonStatusId == 3)
264+
{
265+
await this.activityService.CompleteScormActivity(scoObject);
266+
}
267+
263268
return true;
264269
}
265270
catch (Exception ex)

WebAPI/LearningHub.Nhs.Database/Stored Procedures/Activity/ScormActivityComplete.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-- Modification History
77
--
88
-- 11-06-2021 Killian Davies Initial Revision
9+
-- 22-03-2024 Sarathlal TD-1325
910
-------------------------------------------------------------------------------
1011
CREATE PROCEDURE [activity].[ScormActivityComplete]
1112
(
@@ -23,7 +24,7 @@ BEGIN
2324
DECLARE @DurationSeconds int
2425
DECLARE @ScormActivityDurationLimitHours int = 10 * 60 * 60
2526
DECLARE @AmendDate datetimeoffset(7) = ISNULL(TODATETIMEOFFSET(DATEADD(mi, @UserTimezoneOffset, GETUTCDATE()), @UserTimezoneOffset), SYSDATETIMEOFFSET())
26-
27+
DECLARE @CmiCoreSessionTime NVARCHAR(MAX)
2728
SELECT
2829
@ScormResourceActivityId = [ResourceActivityId],
2930
@ActivityStatusId = CmiCoreLesson_status,
@@ -32,7 +33,8 @@ BEGIN
3233
WHEN (activity.ScormTimeToSeconds(CmiCoreSession_time) >= @ScormActivityDurationLimitHours) THEN (@ScormActivityDurationLimitHours - 1)
3334
ELSE activity.ScormTimeToSeconds(CmiCoreSession_time)
3435
END,
35-
@Score = CmiCoreScoreRaw
36+
@Score = CmiCoreScoreRaw,
37+
@CmiCoreSessionTime = CmiCoreSession_time
3638
FROM
3739
activity.ScormActivity sa
3840
INNER JOIN
@@ -52,7 +54,7 @@ BEGIN
5254
END
5355

5456
-- Validation ported from e-LfH: completed status requires duration > 0
55-
IF (@ActivityStatusId IN (3, 4, 5) AND @DurationSeconds > 0)
57+
IF ((@ActivityStatusId IN (3, 4, 5) AND @DurationSeconds > 0) OR (@ActivityStatusId=3 AND @CmiCoreSessionTime =''))
5658
BEGIN TRY
5759
BEGIN TRAN
5860

@@ -121,6 +123,4 @@ BEGIN
121123
,@ErrorState
122124
);
123125
END CATCH
124-
END
125-
126-
GO
126+
END

0 commit comments

Comments
 (0)