Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ public void GetTimeStringFromMinutes_returns_expected_result(int minutes, string
result.Should().Be(expectedResult);
}

[Test]
[TestCase(0, "0 minutes")]
[TestCase(59, "59 minutes")]
[TestCase(60, "1 hours 0 minutes")]
[TestCase(89, "1 hours 29 minutes")]
[TestCase(2332, "38 hours 52 minutes")]
public void GetTimeStringForScreenReaderFromMinutes_returns_expected_result(int minutes, string expectedResult)
{
// When
var result = DisplayStringHelper.GetTimeStringForScreenReaderFromMinutes(minutes);

// Then
result.Should().Be(expectedResult);
}

[Test]
[TestCase("", "")]
[TestCase("NicePascalCaseString", "Nice Pascal Case String")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using DigitalLearningSolutions.Data.Models.SearchSortFilterPaginate;
using DigitalLearningSolutions.Data.Services;
using DigitalLearningSolutions.Web.Attributes;
using DigitalLearningSolutions.Web.Helpers;
using DigitalLearningSolutions.Web.Models.Enums;
using DigitalLearningSolutions.Web.ViewModels.LearningContent;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -85,6 +86,8 @@ public IActionResult Index(

var model = new LearningContentViewModel(result, availableFilters, brand, tutorials);

Response.UpdateFilterCookie(BrandCoursesFilterCookieName, result.FilterString);

return View(model);
}

Expand Down
5 changes: 5 additions & 0 deletions DigitalLearningSolutions.Web/Helpers/DisplayStringHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public static string GetTimeStringFromMinutes(int minutes)
return minutes < 60 ? $"{minutes}m" : $"{minutes / 60}h {minutes % 60}m";
}

public static string GetTimeStringForScreenReaderFromMinutes(int minutes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we fancy any unit tests for this?

{
return minutes < 60 ? $"{minutes} minutes" : $"{minutes / 60} hours {minutes % 60} minutes";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking, I'm guessing we are fine with "1 hour 0 minutes" rather than going for just "1 hour" whenever we have a whole number of hours? Same sort of question would apply to the tag content of "1h 0m".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine where we have data down to the minute. Also the old site displays these as 1h 0m, and it's been to show and tell.

}

public static string AddSpacesToPascalCaseString(string pascalCaseString)
{
return PascalRegex.Replace(pascalCaseString, " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function getSortValue(
case 'When':
return parseDateAndTime(getElementText(searchableElement, 'when'));
case 'LearningTime':
case 'TotalMins':
return parseNonNegativeIntOrNotApplicable(getElementText(searchableElement, 'learning-time'));
case 'AssessmentScore':
return parseNonNegativeIntOrNotApplicable(getElementText(searchableElement, 'assessment-score'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public BrandCourseViewModel(ApplicationWithSections application)
ApplicationName = application.ApplicationName;
PopularityRating = application.PopularityRating;
DisplayTime = DisplayStringHelper.GetTimeStringFromMinutes(application.TotalMins);
TimeForScreenReader =
DisplayStringHelper.GetTimeStringForScreenReaderFromMinutes(application.TotalMins);
Time = application.TotalMins;
CategoryName = application.CategoryName;
CourseTopic = application.CourseTopic;
Expand All @@ -23,6 +25,7 @@ public BrandCourseViewModel(ApplicationWithSections application)
}

public string DisplayTime { get; set; }
public string TimeForScreenReader { get; set; }
public int Time { get; set; }
public double PopularityRating { get; set; }
public IEnumerable<BrandCourseSectionViewModel> Sections { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@

<div class="nhsuk-details__text">
<div class="tags">
<div class="card-filter-tag" data-filter-value="@Model.CategoryFilter">
<strong class="nhsuk-tag nhsuk-tag--grey">@Model.CategoryName</strong>
</div>

<div class="card-filter-tag" data-filter-value="@Model.TopicFilter">
<strong class="nhsuk-tag nhsuk-tag--grey">@Model.CourseTopic</strong>
</div>

<div class="card-filter-tag">
<strong class="nhsuk-tag nhsuk-tag--grey">@Model.DisplayTime</strong>
<strong class="nhsuk-tag nhsuk-tag--grey" aria-hidden="true">@Model.DisplayTime</strong>
<span class="nhsuk-u-visually-hidden">Length @Model.TimeForScreenReader</span>
<span hidden name="learning-time">@Model.Time</span>
</div>

Expand All @@ -22,29 +31,24 @@
<span hidden name="popularity-score">@Model.PopularityRating</span>
</div>
</div>
<span hidden data-filter-value="@Model.CategoryFilter">
@Model.CategoryName
</span>
<span hidden data-filter-value="@Model.TopicFilter">
@Model.CourseTopic
</span>

<span class="nhsuk-u-margin-bottom-4">
<span class="nhsuk-u-font-weight-bold">Created</span> @Model.CreatedDate.ToString(DateHelper.StandardDateFormat)
<span hidden data-name-for-sorting="created-date">@Model.CreatedDate</span>
</span>

<div>
<div class="header-row nhsuk-u-font-weight-bold">
<div class="value header-row-content">Section</div>
<div class="value header-row-content">Tutorials</div>
</div>
<table>
<tr class="header-row nhsuk-u-font-weight-bold">
<th class="value header-row-content">Section</th>
Comment on lines +40 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NHS tables have specific roles for different table elements. Do we want them here?
https://service-manual.nhs.uk/design-system/components/table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we need them since we are using the correct html elements, looking at the various bits of documentation on them e.g. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/row_role.
e.g. I probably should have had them for the table structure with divs that I had before.

<th class="value header-row-content">Tutorials</th>
</tr>
@foreach (var section in Model.Sections) {
<div class="value-row">
<div class="value">
<tr class="value-row">
<td class="value">
<p class="responsive-header nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-3">Section</p>
<p class="nhsuk-u-margin-bottom-3">@(section.SectionName)</p>
</div>
<div class="value">
</td>
<td class="value">
<p class="responsive-header nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-3">Tutorials</p>
@if (section.Tutorials.Any()) {
@foreach (var tutorial in section.Tutorials) {
Expand All @@ -53,10 +57,10 @@
} else {
<p class="nhsuk-u-margin-bottom-3">No tutorials</p>
}
</div>
</div>
</td>
</tr>
}
</div>
</table>
</div>
</details>
</div>