Skip to content

Commit 0032b3b

Browse files
authored
Merge pull request #2670 from TechnologyEnhancedLearning/Develop/Fixes/TD-3671-Fewcourseswhichdoesnotallowselfenrolment
TD-3671 few courses which does not allow self enrolment
2 parents c461f4b + d21547c commit 0032b3b

File tree

12 files changed

+76
-63
lines changed

12 files changed

+76
-63
lines changed

DigitalLearningSolutions.Data.Migrations/202405031044_AlterGetCurrentCoursesForCandidate_V2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
{
33
using FluentMigrator;
44

5-
[Migration(202405161044)]
5+
[Migration(202405231044)]
66
public class AlterGetCurrentCoursesForCandidate_V2 : Migration
77
{
88
public override void Up()
99
{
10-
Execute.Sql(Properties.Resources.TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc1_up );
10+
Execute.Sql(Properties.Resources.TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc_up );
1111
Execute.Sql(Properties.Resources.TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up );
1212
}
1313
public override void Down()

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

Lines changed: 34 additions & 34 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,16 @@
376376
<data name="TD_4015_Update_GetCompletedCoursesForCandidate_proc_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
377377
<value>..\Scripts\TD-4015-GetCompletedCoursesForCandidateFix_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
378378
</data>
379-
<data name="TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
380-
<value>..\Resources\TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
381-
</data>
382-
<data name="TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc1_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
383-
<value>..\Resources\TD-3671-Alter_GetCurrentCoursesForCandidate_V2_proc1_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
384-
</data>
385379
<data name="TD_3671_Alter_CheckDelegateStatusForCustomisation_func_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
386380
<value>..\Resources\TD_3671_Alter_CheckDelegateStatusForCustomisation_func_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
387381
</data>
388382
<data name="TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc_down" type="System.Resources.ResXFileRef, System.Windows.Forms">
389383
<value>..\Resources\TD-3671-Alter_GetCurrentCoursesForCandidate_V2_proc_down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
390384
</data>
385+
<data name="TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
386+
<value>..\Resources\TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
387+
</data>
388+
<data name="TD_3671_Alter_GetCurrentCoursesForCandidate_V2_proc_up" type="System.Resources.ResXFileRef, System.Windows.Forms">
389+
<value>..\Resources\TD-3671-Alter_GetCurrentCoursesForCandidate_V2_proc_up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
390+
</data>
391391
</root>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ BEGIN
3737
FROM Progress AS p INNER JOIN
3838
Customisations AS cu ON p.CustomisationID = cu.CustomisationID INNER JOIN
3939
Applications AS a ON cu.ApplicationID = a.ApplicationID
40-
WHERE (p.Completed IS NULL) AND (p.RemovedDate IS NULL) AND (p.CandidateID = @CandidateID)AND (cu.CustomisationName <> 'ESR') AND (a.ArchivedDate IS NULL) AND (cu.Active = 1) AND ((p.SubmittedTime > DATEADD(M, -6, getDate()) OR (EnrollmentMethodID <> 1)) OR NOT p.CompleteByDate IS NULL)
40+
WHERE (p.Completed IS NULL) AND (p.RemovedDate IS NULL) AND (p.CandidateID = @CandidateID)AND (cu.CustomisationName <> 'ESR') AND (a.ArchivedDate IS NULL) AND(cu.Active = 1) AND
41+
((p.SubmittedTime > DATEADD(M, -6, getDate()) OR (EnrollmentMethodID <> 1)) OR NOT (p.CompleteByDate IS NULL) AND NOT
42+
(p.SubmittedTime < DATEADD(MONTH, -6, GETDATE()) AND (p.EnrollmentMethodID = 1) AND (p.CompleteByDate < GETDATE())))
4143
ORDER BY p.SubmittedTime Desc
4244
END

DigitalLearningSolutions.Data.Migrations/Resources/TD_3671_Alter_CheckDelegateStatusForCustomisation_func_up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BEGIN
3434
-- Check of current:
3535
if @CustomisationID IN (SELECT CustomisationID
3636
FROM Progress AS p
37-
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime > DATEADD(M, - 6, GETDATE()) OR (EnrollmentMethodID <> 1)) OR NOT p.CompleteByDate IS NULL))
37+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime > DATEADD(M, - 6, GETDATE()) OR (EnrollmentMethodID <> 1)) OR NOT (p.CompleteByDate IS NULL) AND NOT (p.SubmittedTime < DATEADD(MONTH, -6, GETDATE()) AND (p.EnrollmentMethodID = 1) AND (p.CompleteByDate < GETDATE()))))
3838
begin
3939
Set @ResultVar = 3
4040
goto onExit
@@ -50,7 +50,7 @@ end
5050
--Check if Expired:
5151
if @CustomisationID IN (SELECT CustomisationID
5252
FROM Progress AS p
53-
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime <= DATEADD(M, - 6, GETDATE())) AND (EnrollmentMethodID = 1)) AND (p.CompleteByDate IS NULL))
53+
WHERE (Completed IS NULL) AND (RemovedDate IS NULL) AND (CandidateID = @CandidateID) AND ((SubmittedTime <= DATEADD(M, - 6, GETDATE())) AND (EnrollmentMethodID = 1)) AND (p.CompleteByDate IS NULL) AND (p.SubmittedTime < DATEADD(MONTH, -6, GETDATE()) AND (p.EnrollmentMethodID = 1) AND (p.CompleteByDate < GETDATE())))
5454
begin
5555
Set @ResultVar = 1
5656
goto onExit

DigitalLearningSolutions.Data/DataServices/ProgressDataService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface IProgressDataService
1515
{
1616
IEnumerable<Progress> GetDelegateProgressForCourse(int delegateId, int customisationId);
1717

18-
void UpdateProgressSupervisorAndCompleteByDate(int progressId, int supervisorAdminId, DateTime? completeByDate);
18+
void UpdateProgressSupervisorAndCompleteByDate(int progressId, int supervisorAdminId, DateTime? completeByDate, int enrollmentMethodID);
1919

2020
int CreateNewDelegateProgress(
2121
int delegateId,
@@ -143,15 +143,17 @@ FROM Progress
143143
public void UpdateProgressSupervisorAndCompleteByDate(
144144
int progressId,
145145
int supervisorAdminId,
146-
DateTime? completeByDate
146+
DateTime? completeByDate,
147+
int enrollmentMethodID
147148
)
148149
{
149150
connection.Execute(
150151
@"UPDATE Progress SET
151152
SupervisorAdminID = @supervisorAdminId,
152-
CompleteByDate = @completeByDate
153+
CompleteByDate = @completeByDate,
154+
EnrollmentMethodID = @enrollmentMethodID
153155
WHERE ProgressID = @progressId",
154-
new { progressId, supervisorAdminId, completeByDate }
156+
new { progressId, supervisorAdminId, completeByDate, enrollmentMethodID }
155157
);
156158
}
157159

DigitalLearningSolutions.Web.Tests/Services/GroupServiceTests/GroupsServiceEnrolDelegateTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ public void EnrolDelegateOnGroupCourses_updates_existing_progress_record()
348348
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
349349
reusableProgressRecord.ProgressId,
350350
A<int>._,
351-
A<DateTime?>._
351+
A<DateTime?>._,
352+
A<int>._
352353
)
353354
).MustHaveHappened();
354355
}
@@ -384,7 +385,8 @@ public void
384385
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
385386
reusableProgressRecord.ProgressId,
386387
reusableProgressRecord.SupervisorAdminId,
387-
A<DateTime?>._
388+
A<DateTime?>._,
389+
A<int>._
388390
)
389391
).MustHaveHappened();
390392
}
@@ -420,7 +422,8 @@ public void EnrolDelegateOnGroupCourses_update_uses_course_supervisor_id_if_cour
420422
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
421423
reusableProgressRecord.ProgressId,
422424
supervisorId,
423-
A<DateTime?>._
425+
A<DateTime?>._,
426+
A<int>._
424427
)
425428
).MustHaveHappened();
426429
}
@@ -456,7 +459,8 @@ public void
456459
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
457460
reusableProgressRecord.ProgressId,
458461
A<int>._,
459-
null
462+
null,
463+
A<int>._
460464
)
461465
).MustHaveHappened();
462466
}
@@ -494,7 +498,8 @@ public void
494498
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
495499
reusableProgressRecord.ProgressId,
496500
A<int>._,
497-
expectedFutureDate
501+
expectedFutureDate,
502+
A<int>._
498503
)
499504
).MustHaveHappened();
500505
}

DigitalLearningSolutions.Web.Tests/Services/GroupServiceTests/GroupsServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private void DelegateMustNotHaveBeenAddedToAGroup()
721721
private void DelegateProgressRecordMustNotHaveBeenUpdated()
722722
{
723723
A.CallTo(
724-
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._)
724+
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._, A<int>._)
725725
).MustNotHaveHappened();
726726
}
727727

@@ -764,7 +764,7 @@ private void DatabaseModificationsDoNothing()
764764
A.CallTo(() => groupsDataService.AddDelegateToGroup(A<int>._, A<int>._, A<DateTime>._, A<int>._))
765765
.DoesNothing();
766766
A.CallTo(
767-
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._)
767+
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._, A<int>._)
768768
).DoesNothing();
769769
A.CallTo(
770770
() => progressDataService.CreateNewDelegateProgress(

DigitalLearningSolutions.Web.Tests/Services/ProgressServiceTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void UpdateSupervisor_does_not_update_records_if_new_supervisor_matches_c
5858

5959
// Then
6060
A.CallTo(
61-
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._)
61+
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._, A<int>._)
6262
).MustNotHaveHappened();
6363
A.CallTo(
6464
() => progressDataService.ClearAspProgressVerificationRequest(A<int>._)
@@ -83,7 +83,8 @@ public void UpdateSupervisor_updates_records_if_new_supervisor_does_not_match_cu
8383
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
8484
progressId,
8585
newSupervisorId,
86-
A<DateTime?>._
86+
A<DateTime?>._,
87+
A<int>._
8788
)
8889
).MustHaveHappened();
8990
A.CallTo(
@@ -105,7 +106,7 @@ public void UpdateSupervisor_sets_supervisor_id_to_0_if_new_supervisor_is_null()
105106

106107
// Then
107108
A.CallTo(
108-
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(progressId, 0, A<DateTime?>._)
109+
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(progressId, 0, A<DateTime?>._, A<int>._)
109110
).MustHaveHappened();
110111
A.CallTo(
111112
() => progressDataService.ClearAspProgressVerificationRequest(progressId)
@@ -122,7 +123,7 @@ public void UpdateSupervisor_throws_exception_if_no_progress_record_found()
122123
// Then
123124
Assert.Throws<ProgressNotFoundException>(() => progressService.UpdateSupervisor(progressId, null));
124125
A.CallTo(
125-
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._)
126+
() => progressDataService.UpdateProgressSupervisorAndCompleteByDate(A<int>._, A<int>._, A<DateTime?>._, A<int>._)
126127
).MustNotHaveHappened();
127128
A.CallTo(
128129
() => progressDataService.ClearAspProgressVerificationRequest(A<int>._)

DigitalLearningSolutions.Web/Services/EnrolService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public void EnrolDelegateOnCourse(int delegateId, int customisationId, int custo
102102
progressDataService.UpdateProgressSupervisorAndCompleteByDate(
103103
progressRecord.ProgressId,
104104
supervisorAdminId ?? 0,
105-
completeByDate
105+
completeByDate,
106+
2
106107
);
107108
}
108109
}

0 commit comments

Comments
 (0)