Skip to content

Commit 920b0d4

Browse files
committed
Merge branch 'DLS-Release-v1.1.2' into UAT
2 parents b1a416c + 2f1cdd4 commit 920b0d4

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

DigitalLearningSolutions.Web/Controllers/TrackingSystem/CourseSetup/CourseSetupController.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,15 @@ public IActionResult SetSectionContent(int sectionIndex)
460460
}
461461

462462
var showDiagnostic = data.Application!.DiagAssess;
463-
if (data.EditCourseContent)
463+
var tutorial = GetTutorialsFromSectionContentData(data.SectionContentData, tutorials);
464+
if (tutorial.Count() == 0)
464465
{
465-
var tutorial = GetTutorialsFromSectionContentData(data.SectionContentData, tutorials);
466-
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorial);
467-
return View("AddNewCentreCourse/SetSectionContent", model);
468-
}
469-
else
470-
{
471-
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials);
472-
return View("AddNewCentreCourse/SetSectionContent", model);
466+
var models = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials);
467+
return View("AddNewCentreCourse/SetSectionContent", models);
473468
}
469+
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorial);
470+
return View("AddNewCentreCourse/SetSectionContent", model);
471+
474472

475473
}
476474

@@ -501,6 +499,21 @@ string action
501499
public IActionResult Summary()
502500
{
503501
var data = multiPageFormService.GetMultiPageFormData<AddNewCentreCourseTempData>(MultiPageFormDataFeature.AddNewCourse, TempData).GetAwaiter().GetResult();
502+
var updatedSections = new List<SectionContentTempData>();
503+
foreach (var item in data.CourseContentData.SelectedSectionIds)
504+
{
505+
var tutorialsForSection = tutorialService.GetTutorialsForSection(item).ToList();
506+
507+
var matchingSections = data.SectionContentData
508+
.Where(section => section.Tutorials.Any(t => tutorialsForSection.Any(tf => tf.TutorialId == t.TutorialId)))
509+
.ToList();
510+
511+
updatedSections.AddRange(matchingSections);
512+
}
513+
514+
updatedSections = updatedSections.Distinct().ToList();
515+
data.SectionContentData = updatedSections;
516+
multiPageFormService.SetMultiPageFormData(data, MultiPageFormDataFeature.AddNewCourse, TempData);
504517

505518
var model = new SummaryViewModel(data!);
506519

@@ -664,11 +677,11 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
664677
}
665678
}
666679
if (sectionsToRemove.Count > 0)
667-
{
668-
foreach (var section in sectionsToRemove)
669680
{
670-
data.SectionContentData.Remove(section);
671-
}
681+
foreach (var section in sectionsToRemove)
682+
{
683+
data.SectionContentData.Remove(section);
684+
}
672685
}
673686
data!.SectionContentData!.Add(
674687
new SectionContentTempData(

DigitalLearningSolutions.Web/Views/TrackingSystem/CourseSetup/AddNewCentreCourse/SetSectionContent.cshtml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,37 @@
33
@model SetSectionContentViewModel
44

55
@{
6-
ViewData["Title"] = "Set section content";
7-
var backLinkRouteData = new Dictionary<string, string> { { "index", Model.Index.ToString() } };
6+
ViewData["Title"] = "Set section content";
7+
var sectionIndex = Model.Index == 0 ? Model.Index : Model.Index - 1;
8+
var backLinkRouteData = new Dictionary<string, string> { { "index", Model.Index.ToString() } };
89
}
910

1011
<div class="nhsuk-grid-row">
11-
<div class="nhsuk-grid-column-full">
12-
<h1 class="nhsuk-heading-xl">@ViewData["Title"]</h1>
12+
<div class="nhsuk-grid-column-full">
13+
<h1 class="nhsuk-heading-xl">@ViewData["Title"]</h1>
1314

14-
<vc:field-name-value-display display-name="Section" field-value="@Model.SectionName" />
15+
<vc:field-name-value-display display-name="Section" field-value="@Model.SectionName" />
1516

16-
<form method="post" novalidate asp-action="SetSectionContent">
17-
<input type="hidden" asp-for="Index" />
17+
<form method="post" novalidate asp-action="SetSectionContent">
18+
<input type="hidden" asp-for="Index" />
1819

19-
<partial name="../CourseContent/_EditSectionContentFormInputs" model="Model" />
20+
<partial name="../CourseContent/_EditSectionContentFormInputs" model="Model" />
2021

21-
<button name="action" class="nhsuk-button" type="submit" value="@CourseSetupController.SaveAction">Next</button>
22-
</form>
23-
@if (Model.Index == 0)
24-
{
25-
<vc:back-link asp-controller="CourseSetup" asp-action="SetCourseContent" link-text="Go back" />
26-
}
27-
else
28-
{
29-
<vc:back-link asp-controller="CourseSetup" asp-action="SetSectionContent" asp-all-route-data="@backLinkRouteData" link-text="Go back" />
30-
}
31-
</div>
22+
<button name="action" class="nhsuk-button" type="submit" value="@CourseSetupController.SaveAction">Next</button>
23+
</form>
24+
@if (Model.Index == 0)
25+
{
26+
<vc:back-link asp-controller="CourseSetup" asp-action="SetCourseContent" link-text="Go back" />
27+
}
28+
else
29+
{
30+
<a asp-controller="CourseSetup" asp-action="SetSectionContent" asp-route-sectionIndex="@sectionIndex">
31+
&lt; Go back
32+
</a>
33+
}
34+
</div>
3235
</div>
3336

3437
@section scripts {
35-
<script src="@Url.Content("~/js/trackingSystem/editCourseContent.js")" asp-append-version="true"></script>
38+
<script src="@Url.Content("~/js/trackingSystem/editCourseContent.js")" asp-append-version="true"></script>
3639
}

0 commit comments

Comments
 (0)