Skip to content

Commit 14b6583

Browse files
Merge remote-tracking branch 'origin/Release-2024.32' into Develop/Fixes/TD-4137-'Switchapplication'navigationlinkshouldberemovedfrom'Givepagefeedback'screensforloggedinuser
2 parents 579645a + 0fbbe4c commit 14b6583

File tree

10 files changed

+101
-69
lines changed

10 files changed

+101
-69
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ FROM Customisations cu
337337
cc.CategoryName,
338338
ct.CourseTopic,
339339
CASE WHEN ({TutorialWithLearningCountQuery}) > 0 THEN 1 ELSE 0 END AS HasLearning,
340-
CASE WHEN ({TutorialWithDiagnosticCountQuery}) > 0 THEN 1 ELSE 0 END AS HasDiagnostic
340+
CASE WHEN ({TutorialWithDiagnosticCountQuery}) > 0 THEN 1 ELSE 0 END AS HasDiagnostic,
341+
CASE WHEN ap.ArchivedDate IS NULL THEN 0 ELSE 1 END AS Archived
341342
FROM Customisations AS c
342343
INNER JOIN Applications AS ap ON ap.ApplicationID = c.ApplicationID
343344
INNER JOIN CourseCategories AS cc ON ap.CourseCategoryId = cc.CourseCategoryId
@@ -869,8 +870,8 @@ public IEnumerable<CourseStatistics> GetNonArchivedCourseStatisticsAtCentreFilte
869870

870871
public IEnumerable<DelegateCourseInfo> GetDelegateCoursesInfo(int delegateId)
871872
{
872-
return connection.Query<DelegateCourseInfo>(
873-
$@"{selectDelegateCourseInfoQuery}
873+
return connection.Query<DelegateCourseInfo>(
874+
$@"{selectDelegateCourseInfoQuery}
874875
WHERE pr.CandidateID = @delegateId
875876
AND pr.RemovedDate IS NULL
876877
AND ap.DefaultContentTypeID <> 4
@@ -914,8 +915,8 @@ AND ap.DefaultContentTypeID <> 4
914915
u.ProfessionalRegistrationNumber,
915916
da.CentreID,
916917
ap.ArchivedDate",
917-
new { delegateId }
918-
);
918+
new { delegateId }
919+
);
919920
}
920921

921922
public DelegateCourseInfo? GetDelegateCourseInfoByProgressId(int progressId)

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/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;

DigitalLearningSolutions.Web/ServiceFilter/VerifyAdminUserCanAccessGroup.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public void OnActionExecuting(ActionExecutingContext context)
2626
var groupId = int.Parse(context.RouteData.Values["groupId"].ToString()!);
2727
var groupCentreId = groupsService.GetGroupCentreId(groupId);
2828

29-
if (controller.User.GetCentreIdKnownNotNull() != groupCentreId)
29+
if (groupCentreId == 0)
30+
{
31+
context.Result = new RedirectToActionResult("StatusCode", "LearningSolutions", new { code = 410 });
32+
}
33+
else if (controller.User.GetCentreIdKnownNotNull() != groupCentreId)
3034
{
3135
context.Result = new NotFoundResult();
3236
}

DigitalLearningSolutions.Web/Services/CourseService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ int groupId
384384
)
385385
{
386386
var allPossibleCourses = courseDataService.GetCoursesAvailableToCentreByCategory(centreId, categoryId)
387-
.Where(c => c.Active);
387+
.Where(c => c.Active && !c.Archived);
388388

389389
var groupCourseIds = groupsDataService.GetGroupCoursesVisibleToCentre(centreId)
390390
.Where(gc => gc.IsUsable && gc.GroupId == groupId)

DigitalLearningSolutions.Web/Views/ClaimAccount/Index.cshtml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,66 @@
22
@model ClaimAccountViewModel
33

44
@{
5-
ViewData["Title"] = "Complete registration";
5+
ViewData["Title"] = "Complete registration";
66

7-
var routeData = new Dictionary<string, string> {
7+
var routeData = new Dictionary<string, string> {
88
{ "email", Model.Email },
99
{ "code", Model.RegistrationConfirmationHash },
1010
};
1111
}
1212

1313
<div class="nhsuk-grid-row">
14-
<div class="nhsuk-grid-column-full">
14+
<div class="nhsuk-grid-column-full">
1515

16-
<h1 class="nhsuk-heading-x1" id="app-page-heading">
17-
Complete registration
18-
</h1>
16+
<h1 class="nhsuk-heading-x1" id="app-page-heading">
17+
Complete registration
18+
</h1>
1919

20-
<p class="nhsuk-body-m">A new delegate record has been created for you by an administrator.</p>
20+
<p class="nhsuk-body-m">A new delegate record has been created for you by an administrator.</p>
2121

22-
<partial name="_DelegateRecordSummary" model="@Model" />
22+
<partial name="_DelegateRecordSummary" model="@Model" />
2323

24-
@if (Model.IdOfUserMatchingEmailIfAny != null)
25-
{
26-
if (Model.UserMatchingEmailIsActive)
27-
{
28-
<p class="nhsuk-body-m">
29-
A DLS user account is already registered with this email address. If that account belongs to you, you can link this delegate record to your login.
30-
</p>
24+
@if (Model.IdOfUserMatchingEmailIfAny != null)
25+
{
26+
if (Model.UserMatchingEmailIsActive)
27+
{
28+
<p class="nhsuk-body-m">
29+
A DLS user account is already registered with this email address. If that account belongs to you, you can link this delegate record to your login.
30+
</p>
3131

32-
<vc:action-link asp-controller="ClaimAccount"
33-
asp-action="LinkDlsAccount"
34-
asp-all-route-data="@routeData"
35-
link-text="Link this record" />
36-
}
37-
else
38-
{
39-
<p class="nhsuk-body-m">
40-
There is already an inactive DLS user account associated with this email address. To request reactivation of the user account and link this delegate record to the account, please contact <a href="mailto:@Model.SupportEmail">@Model.SupportEmail</a>.
41-
</p>
42-
}
43-
}
44-
else
45-
{
46-
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am an existing DLS user</h2>
47-
<p class="nhsuk-hint">
48-
If you have used DLS in the past (for example, at another organisation or university), we <b>recommend</b> that you link this record to your existing login.
49-
</p>
32+
<vc:action-link asp-controller="ClaimAccount"
33+
asp-action="VerifyLinkDlsAccount"
34+
asp-all-route-data="@routeData"
35+
link-text="Link this record" />
36+
}
37+
else
38+
{
39+
<p class="nhsuk-body-m">
40+
There is already an inactive DLS user account associated with this email address. To request reactivation of the user account and link this delegate record to the account, please contact <a href="mailto:@Model.SupportEmail">@Model.SupportEmail</a>.
41+
</p>
42+
}
43+
}
44+
else
45+
{
46+
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am an existing DLS user</h2>
47+
<p class="nhsuk-hint">
48+
If you have used DLS in the past (for example, at another organisation or university), we <b>recommend</b> that you link this record to your existing login.
49+
</p>
5050

51-
<vc:action-link asp-controller="ClaimAccount"
52-
asp-action="LinkDlsAccount"
53-
asp-all-route-data="@routeData"
54-
link-text="Use existing login and link delegate record" />
51+
<vc:action-link asp-controller="ClaimAccount"
52+
asp-action="LinkDlsAccount"
53+
asp-all-route-data="@routeData"
54+
link-text="Use existing login and link delegate record" />
5555

56-
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am a new DLS user</h2>
57-
<p class="nhsuk-hint">
58-
If you have never accessed DLS before, please activate this delegate record to log in. A new DLS user account will be created.
59-
</p>
56+
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am a new DLS user</h2>
57+
<p class="nhsuk-hint">
58+
If you have never accessed DLS before, please activate this delegate record to log in. A new DLS user account will be created.
59+
</p>
6060

61-
<vc:action-link asp-controller="ClaimAccount"
62-
asp-action="CompleteRegistration"
63-
asp-all-route-data="@routeData"
64-
link-text="Create new login and activate delegate record" />
65-
}
66-
</div>
61+
<vc:action-link asp-controller="ClaimAccount"
62+
asp-action="CompleteRegistration"
63+
asp-all-route-data="@routeData"
64+
link-text="Create new login and activate delegate record" />
65+
}
66+
</div>
6767
</div>

DigitalLearningSolutions.Web/Views/UserFeedback/UserFeedbackComplete.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
<div class="nhsuk-grid-row">
3333
<div class="nhsuk-grid-column-full">
34-
<h2 class="nhsuk-caption-l">Join our user research panel</h2>
3534
<h1 id="page-heading" class="nhsuk-heading-xl">Thank you for your feedback</h1>
3635
</div>
3736
<div class="nhsuk-grid-column-two-thirds">

0 commit comments

Comments
 (0)