Skip to content

Commit 8c51508

Browse files
Merge remote-tracking branch 'origin/Release-2024.32' into Develop/Fixes/TD-4238-Launchingfewcoursesfrom'Currentactivities'orfrom'Coursesetup'seeingbacklinkasCompletedactivities'
2 parents cfea661 + 0fbbe4c commit 8c51508

File tree

19 files changed

+177
-130
lines changed

19 files changed

+177
-130
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ IEnumerable<CourseDelegateForExport> GetCourseDelegatesForExport(string searchSt
122122
int customisationId, int centreId, bool? isDelegateActive, bool? isProgressLocked, bool? removed, bool? hasCompleted, string? answer1, string? answer2, string? answer3);
123123

124124
int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
125-
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId);
125+
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId);
126126

127127
bool IsCourseCompleted(int candidateId, int customisationId);
128128

@@ -338,7 +338,8 @@ FROM Customisations cu
338338
cc.CategoryName,
339339
ct.CourseTopic,
340340
CASE WHEN ({TutorialWithLearningCountQuery}) > 0 THEN 1 ELSE 0 END AS HasLearning,
341-
CASE WHEN ({TutorialWithDiagnosticCountQuery}) > 0 THEN 1 ELSE 0 END AS HasDiagnostic
341+
CASE WHEN ({TutorialWithDiagnosticCountQuery}) > 0 THEN 1 ELSE 0 END AS HasDiagnostic,
342+
CASE WHEN ap.ArchivedDate IS NULL THEN 0 ELSE 1 END AS Archived
342343
FROM Customisations AS c
343344
INNER JOIN Applications AS ap ON ap.ApplicationID = c.ApplicationID
344345
INNER JOIN CourseCategories AS cc ON ap.CourseCategoryId = cc.CourseCategoryId
@@ -431,23 +432,24 @@ public void RemoveCurrentCourse(int progressId, int candidateId, RemovalMethod r
431432
}
432433

433434
public int EnrolOnActivitySelfAssessment(int selfAssessmentId, int candidateId, int supervisorId, string adminEmail,
434-
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId)
435+
int selfAssessmentSupervisorRoleId, DateTime? completeByDate, int delegateUserId, int centreId, int? enrolledByAdminId)
435436
{
436437
IClockUtility clockUtility = new ClockUtility();
437438
DateTime startedDate = clockUtility.UtcNow;
438-
DateTime lastAccessed = startedDate;
439+
DateTime? lastAccessed = null;
439440
dynamic? completeByDateDynamic = null;
441+
int enrolmentMethodId = 2;
440442
if (completeByDate == null || completeByDate.GetValueOrDefault().Year > 1753)
441443
{
442444
completeByDateDynamic = completeByDate!;
443445
}
444-
var candidateAssessmentId = (int)connection.ExecuteScalar(
446+
var candidateAssessmentId = Convert.ToInt32(connection.ExecuteScalar(
445447
@"SELECT COALESCE
446448
((SELECT ID
447449
FROM CandidateAssessments
448450
WHERE (SelfAssessmentID = @selfAssessmentId) AND (DelegateUserID = @delegateUserId) AND (CompletedDate IS NULL)), 0) AS ID",
449451
new { selfAssessmentId, delegateUserId }
450-
);
452+
));
451453

452454
if (candidateAssessmentId == 0)
453455
{
@@ -458,24 +460,28 @@ FROM CandidateAssessments
458460
,[StartedDate]
459461
,[LastAccessed]
460462
,[CompleteByDate]
461-
,[CentreID])
463+
,[CentreID]
464+
,[EnrolmentMethodId]
465+
,[EnrolledByAdminId])
462466
OUTPUT INSERTED.Id
463467
VALUES
464468
(@DelegateUserID,
465469
@selfAssessmentId,
466470
@startedDate,
467471
@lastAccessed,
468472
@completeByDateDynamic,
469-
@centreId);",
470-
new { delegateUserId, selfAssessmentId, startedDate, lastAccessed, completeByDateDynamic, centreId }
473+
@centreId,
474+
@enrolmentMethodId,
475+
@enrolledByAdminId);",
476+
new { delegateUserId, selfAssessmentId, startedDate, lastAccessed, completeByDateDynamic, centreId, enrolmentMethodId, enrolledByAdminId }
471477
);
472478
}
473479

474-
int supervisorDelegateId = (int)connection.ExecuteScalar(
480+
int supervisorDelegateId = Convert.ToInt32(connection.ExecuteScalar(
475481
@"SELECT COALESCE
476482
((SELECT TOP 1 ID FROM SupervisorDelegates WHERE SupervisorAdminID = @supervisorId AND DelegateUserId = @delegateUserId), 0) AS ID",
477483
new { supervisorId, delegateUserId }
478-
);
484+
));
479485
if (supervisorDelegateId == 0 && supervisorId > 0)
480486
{
481487
supervisorDelegateId = connection.QuerySingle<int>(@"INSERT INTO SupervisorDelegates
@@ -502,11 +508,11 @@ LEFT OUTER JOIN UserCentreDetails AS UCD ON
502508

503509
if (candidateAssessmentId > 0 && supervisorDelegateId > 0 && selfAssessmentSupervisorRoleId > 0)
504510
{
505-
int candidateAssessmentSupervisorsId = (int)connection.ExecuteScalar(
511+
int candidateAssessmentSupervisorsId = Convert.ToInt32(connection.ExecuteScalar(
506512
@"SELECT COALESCE
507513
((SELECT TOP 1 ID FROM CandidateAssessmentSupervisors WHERE CandidateAssessmentID = @candidateAssessmentID AND SupervisorDelegateId = @supervisorDelegateId), 0) AS ID",
508514
new { candidateAssessmentId, supervisorDelegateId }
509-
);
515+
));
510516

511517
if (candidateAssessmentSupervisorsId == 0)
512518
{
@@ -548,13 +554,13 @@ BEGIN TRANSACTION
548554

549555
public void EnrolOnSelfAssessment(int selfAssessmentId, int delegateUserId, int centreId)
550556
{
551-
var enrolmentExists = (int)connection.ExecuteScalar(
557+
var enrolmentExists = Convert.ToInt32(connection.ExecuteScalar(
552558
@"SELECT COALESCE
553559
((SELECT ID
554560
FROM CandidateAssessments
555561
WHERE (SelfAssessmentID = @selfAssessmentId) AND (DelegateUserID = @delegateUserId) AND (CompletedDate IS NULL)), 0) AS ID",
556562
new { selfAssessmentId, delegateUserId }
557-
);
563+
));
558564

559565
if (enrolmentExists > 0)
560566
{
@@ -639,7 +645,7 @@ OUTPUT Inserted.ID
639645

640646
public int GetNumberOfActiveCoursesAtCentreFilteredByCategory(int centreId, int? adminCategoryId)
641647
{
642-
return (int)connection.ExecuteScalar(
648+
return Convert.ToInt32(connection.ExecuteScalar(
643649
@"SELECT COUNT(*)
644650
FROM dbo.Customisations AS cu
645651
INNER JOIN dbo.CentreApplications AS ca ON ca.ApplicationID = cu.ApplicationID
@@ -650,7 +656,7 @@ FROM dbo.Customisations AS cu
650656
AND ca.CentreID = @centreId
651657
AND ap.DefaultContentTypeID <> 4",
652658
new { centreId, adminCategoryId }
653-
);
659+
));
654660
}
655661

656662
public IEnumerable<CourseStatistics> GetCourseStatisticsAtCentreFilteredByCategory(
@@ -865,8 +871,8 @@ public IEnumerable<CourseStatistics> GetNonArchivedCourseStatisticsAtCentreFilte
865871

866872
public IEnumerable<DelegateCourseInfo> GetDelegateCoursesInfo(int delegateId)
867873
{
868-
return connection.Query<DelegateCourseInfo>(
869-
$@"{selectDelegateCourseInfoQuery}
874+
return connection.Query<DelegateCourseInfo>(
875+
$@"{selectDelegateCourseInfoQuery}
870876
WHERE pr.CandidateID = @delegateId
871877
AND pr.RemovedDate IS NULL
872878
AND ap.DefaultContentTypeID <> 4
@@ -910,8 +916,8 @@ AND ap.DefaultContentTypeID <> 4
910916
u.ProfessionalRegistrationNumber,
911917
da.CentreID,
912918
ap.ArchivedDate",
913-
new { delegateId }
914-
);
919+
new { delegateId }
920+
);
915921
}
916922

917923
public DelegateCourseInfo? GetDelegateCourseInfoByProgressId(int progressId)

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/CandidateAssessmentsDataService.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public IEnumerable<CurrentSelfAssessment> GetSelfAssessmentsForCandidate(int del
3232
SelfAssessment. CentreName,
3333
SelfAssessment.EnrolmentMethodId,
3434
Signoff.SignedOff,
35-
Signoff.Verified FROM (SELECT
35+
Signoff.Verified,
36+
EnrolledByForename +' '+EnrolledBySurname AS EnrolledByFullName
37+
FROM (SELECT
3638
CA.SelfAssessmentID AS Id,
3739
SA.Name,
3840
SA.Description,
@@ -52,22 +54,27 @@ Signoff.Verified FROM (SELECT
5254
1 AS IsSelfAssessment,
5355
CA.SubmittedDate,
5456
CR.CentreName AS CentreName,
55-
CA.EnrolmentMethodId
56-
FROM Centres AS CR INNER JOIN
57+
CA.EnrolmentMethodId,
58+
uEnrolledBy.FirstName AS EnrolledByForename,
59+
uEnrolledBy.LastName AS EnrolledBySurname
60+
FROM Centres AS CR INNER JOIN
5761
CandidateAssessments AS CA INNER JOIN
5862
SelfAssessments AS SA ON CA.SelfAssessmentID = SA.ID ON CR.CentreID = CA.CentreID INNER JOIN
5963
CentreSelfAssessments AS csa ON csa.SelfAssessmentID = SA.ID AND csa.CentreID = @centreId LEFT OUTER JOIN
6064
Competencies AS C RIGHT OUTER JOIN
6165
SelfAssessmentStructure AS SAS ON C.ID = SAS.CompetencyID ON CA.SelfAssessmentID = SAS.SelfAssessmentID LEFT OUTER JOIN
6266
CandidateAssessmentSupervisors AS cas ON ca.ID =cas.CandidateAssessmentID LEFT OUTER JOIN
63-
CandidateAssessmentSupervisorVerifications AS casv ON casv.CandidateAssessmentSupervisorID = cas.ID
67+
CandidateAssessmentSupervisorVerifications AS casv ON casv.CandidateAssessmentSupervisorID = cas.ID LEFT OUTER JOIN
68+
AdminAccounts AS aaEnrolledBy ON aaEnrolledBy.ID = CA.EnrolledByAdminID LEFT OUTER JOIN
69+
Users AS uEnrolledBy ON uEnrolledBy.ID = aaEnrolledBy.UserID
6470
WHERE (CA.DelegateUserID = @delegateUserId) AND (CA.RemovedDate IS NULL) AND (CA.CompletedDate IS NULL)
6571
GROUP BY
6672
CA.SelfAssessmentID, SA.Name, SA.Description, SA.IncludesSignposting, SA.SupervisorResultsReview,
6773
SA.ReviewerCommentsLabel, SA.IncludeRequirementsFilters,
6874
COALESCE(SA.Vocabulary, 'Capability'), CA.StartedDate, CA.LastAccessed, CA.CompleteByDate,
6975
CA.ID,
70-
CA.UserBookmark, CA.UnprocessedUpdates, CA.LaunchCount, CA.SubmittedDate, CR.CentreName,CA.EnrolmentMethodId)SelfAssessment LEFT OUTER JOIN
76+
CA.UserBookmark, CA.UnprocessedUpdates, CA.LaunchCount, CA.SubmittedDate, CR.CentreName,CA.EnrolmentMethodId,
77+
uEnrolledBy.FirstName,uEnrolledBy.LastName)SelfAssessment LEFT OUTER JOIN
7178
(SELECT SelfAssessmentID,casv.SignedOff,MAX(casv.Verified) Verified FROM
7279
CandidateAssessments AS CA LEFT OUTER JOIN
7380
CandidateAssessmentSupervisors AS cas ON ca.ID =cas.CandidateAssessmentID LEFT OUTER JOIN

DigitalLearningSolutions.Data/Models/SelfAssessments/CurrentSelfAssessment.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ public class CurrentSelfAssessment : SelfAssessment
2323
public bool IsSameCentre { get; set; }
2424
public int? DelegateUserId { get; set; }
2525
public string? DelegateName { get; set; }
26+
public string? EnrolledByFullName { get; set; }
2627
}
2728
}

DigitalLearningSolutions.Web.Tests/Services/CourseServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ public void GetEligibleCoursesToAddToGroup_does_not_return_courses_already_in_gr
784784
var result = courseService.GetEligibleCoursesToAddToGroup(centreId, categoryId, groupId).ToList();
785785

786786
// Then
787-
result.Should().HaveCount(4);
787+
result.Should().HaveCount(3);
788788
result.Should().NotContain(c => c.CustomisationId == 2);
789789
}
790790

DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ public IActionResult Confirmation()
176176
return View(model);
177177
}
178178

179+
[HttpGet]
180+
public IActionResult VerifyLinkDlsAccount(string email, string code)
181+
{
182+
var userId = userService.GetUserAccountByEmailAddress(email).Id;
183+
var model = GetViewModelIfValidParameters(email, code, userId);
184+
var actionResult = ValidateClaimAccountViewModelForLinkingAccounts(userId, model);
185+
186+
if (actionResult != null)
187+
{
188+
return actionResult;
189+
}
190+
191+
return RedirectToAction("LinkDlsAccount", new { email, code });
192+
}
193+
179194
[Authorize(Policy = CustomPolicies.BasicUser)]
180195
[HttpGet]
181196
public IActionResult LinkDlsAccount(string email, string code)
@@ -219,23 +234,20 @@ public IActionResult AccountsLinked(string centreName)
219234
return View(model);
220235
}
221236

222-
[Authorize(Policy = CustomPolicies.BasicUser)]
223237
[HttpGet]
224238
public IActionResult WrongUser(string email, string centreName)
225239
{
226240
var model = new ClaimAccountViewModel { Email = email, CentreName = centreName };
227241
return View(model);
228242
}
229243

230-
[Authorize(Policy = CustomPolicies.BasicUser)]
231244
[HttpGet]
232245
public IActionResult AccountAlreadyExists(string email, string centreName)
233246
{
234247
var model = new ClaimAccountViewModel { Email = email, CentreName = centreName };
235248
return View(model);
236249
}
237250

238-
[Authorize(Policy = CustomPolicies.BasicUser)]
239251
[HttpGet]
240252
public IActionResult AdminAccountAlreadyExists(string email, string centreName)
241253
{

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/EnrolController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ public IActionResult EnrolDelegateSummary()
325325
sessionEnrol.SelfAssessmentSupervisorRoleId.GetValueOrDefault(),
326326
sessionEnrol.CompleteByDate,
327327
(int)sessionEnrol.DelegateUserID,
328-
centreId
328+
centreId,
329+
GetAdminID()
329330
);
330331

331332
}

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/GroupDelegatesController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ public IActionResult SelectDelegateAllItems(int groupId)
158158
var jobGroups = jobGroupsService.GetJobGroupsAlphabetical();
159159
var customPrompts = promptsService.GetCentreRegistrationPrompts(centreId);
160160
var delegateUsers = userService.GetDelegatesNotRegisteredForGroupByGroupId(groupId, centreId);
161-
161+
var groups = groupsService.GetActiveGroups(centreId);
162162
var model = new SelectDelegateAllItemsViewModel(
163163
delegateUsers,
164164
jobGroups,
165165
customPrompts,
166-
groupId
166+
groupId,
167+
groups
167168
);
168169

169170
return View(model);

DigitalLearningSolutions.Web/Controllers/UserFeedbackController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ public IActionResult Index(string sourceUrl, string sourcePageTitle)
5252
TaskRating = null,
5353
};
5454

55+
if(sourcePageTitle == "Digital Learning Solutions - Page no longer available")
56+
{
57+
var url = ContentUrlHelper.ReplaceUrlSegment(sourceUrl);
58+
_userFeedbackViewModel.SourceUrl = url;
59+
_userFeedbackViewModel.SourcePageTitle = "Welcome";
60+
}
61+
5562
if (_userFeedbackViewModel.UserId == null || _userFeedbackViewModel.UserId == 0)
5663
{
5764
return GuestFeedbackStart(_userFeedbackViewModel);

DigitalLearningSolutions.Web/Helpers/ContentUrlHelper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,17 @@ public static string GetContentPath(IConfiguration config, string videoPath)
2222

2323
public static string? GetNullableContentPath(IConfiguration config, string? videoPath) =>
2424
videoPath != null ? GetContentPath(config, videoPath) : null;
25+
26+
public static string ReplaceUrlSegment(string sourceUrl)
27+
{
28+
string errorSegment = "LearningSolutions/StatusCode/410";
29+
string welcomeSegment = "Home/Welcome";
30+
31+
if (sourceUrl.Contains(errorSegment))
32+
{
33+
return sourceUrl.Replace(errorSegment, welcomeSegment);
34+
}
35+
return sourceUrl;
36+
}
2537
}
2638
}

DigitalLearningSolutions.Web/Helpers/FilterableTagHelper.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,13 @@ CourseStatistics courseStatistics
104104
{
105105
tags.Add(new SearchableTagViewModel(CourseStatusFilterOptions.IsInactive));
106106
}
107-
if (courseStatistics.Active)
107+
if (courseStatistics.HideInLearnerPortal)
108108
{
109-
if (courseStatistics.HideInLearnerPortal)
110-
{
111-
tags.Add(new SearchableTagViewModel(CourseVisibilityFilterOptions.IsHiddenInLearningPortal));
112-
}
113-
else
114-
{
115-
tags.Add(new SearchableTagViewModel(CourseVisibilityFilterOptions.IsNotHiddenInLearningPortal));
116-
}
109+
tags.Add(new SearchableTagViewModel(CourseVisibilityFilterOptions.IsHiddenInLearningPortal));
110+
}
111+
else
112+
{
113+
tags.Add(new SearchableTagViewModel(CourseVisibilityFilterOptions.IsNotHiddenInLearningPortal));
117114
}
118115
return tags;
119116
}
@@ -235,7 +232,7 @@ public static IEnumerable<SearchableTagViewModel> GetCurrentTagsForSelfAssessmen
235232
? new SearchableTagViewModel(SelfAssessmentSignedOffFilterOptions.SignedOff)
236233
: new SearchableTagViewModel(SelfAssessmentSignedOffFilterOptions.NotSignedOff);
237234
tags.Add(signedOffTag);
238-
235+
239236
}
240237

241238
return tags;

0 commit comments

Comments
 (0)