Skip to content

Commit b116823

Browse files
authored
Merge pull request #3060 from TechnologyEnhancedLearning/Develop/Fixes/TD-4340-Issuewiththe'Coursecontent'changelinkwhencreatingacoursefrom'Coursesetup'screen
TD-4340 Issue with the 'Course content' change link when creating a course from 'Course set up' screen
2 parents 215bd20 + 99482e1 commit b116823

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

DigitalLearningSolutions.Data/Models/MultiPageFormData/AddNewCentreCourse/AddNewCentreCourseTempData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public AddNewCentreCourseTempData()
1717
public CourseOptionsTempData? CourseOptionsData { get; set; }
1818
public CourseContentTempData? CourseContentData { get; set; }
1919
public List<SectionContentTempData>? SectionContentData { get; set; }
20-
20+
public bool EditCourseContent { get; set; }
2121
public void SetApplicationAndResetModels(ApplicationDetails application)
2222
{
2323
if (Application == application)

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/CourseSetup/CourseSetupControllerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public void SetCourseContent_get_redirects_to_summary_if_application_has_no_sect
416416
).Returns(new List<Section>());
417417

418418
// When
419-
var result = controller.SetCourseContent();
419+
var result = controller.SetCourseContent(false);
420420

421421
// Then
422422
result.Should().BeRedirectToActionResult().WithActionName("Summary");

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,22 +365,24 @@ public IActionResult SetCourseOptions(EditCourseOptionsFormData model)
365365
data!.CourseOptionsData = model.ToCourseOptionsTempData();
366366
multiPageFormService.SetMultiPageFormData(data, MultiPageFormDataFeature.AddNewCourse, TempData);
367367

368-
return RedirectToAction("SetCourseContent");
368+
return RedirectToAction("SetCourseContent", false);
369369
}
370370

371371
[HttpGet("AddCourse/SetCourseContent")]
372372
[TypeFilter(
373373
typeof(RedirectMissingMultiPageFormData),
374374
Arguments = new object[] { nameof(MultiPageFormDataFeature.AddNewCourse) }
375375
)]
376-
public IActionResult SetCourseContent()
376+
public IActionResult SetCourseContent(bool editCourseContent)
377377
{
378378
var data = multiPageFormService.GetMultiPageFormData<AddNewCentreCourseTempData>(MultiPageFormDataFeature.AddNewCourse, TempData).GetAwaiter().GetResult();
379379

380380
if (!sectionService.GetSectionsThatHaveTutorialsForApplication(data!.Application!.ApplicationId).Any())
381381
{
382382
return RedirectToAction("Summary");
383383
}
384+
data.EditCourseContent = editCourseContent;
385+
multiPageFormService.SetMultiPageFormData(data, MultiPageFormDataFeature.AddNewCourse, TempData);
384386

385387
var model = data!.CourseContentData != null
386388
? new SetCourseContentViewModel(data.CourseContentData)
@@ -457,7 +459,7 @@ public IActionResult SetSectionContent(int sectionIndex)
457459
}
458460

459461
var showDiagnostic = data.Application!.DiagAssess;
460-
if (data.SectionContentData != null && data.SectionContentData.Count >=3 )
462+
if (data.EditCourseContent)
461463
{
462464
var tutorial = GetTutorialsFromSectionContentData(data.SectionContentData, tutorials);
463465
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorial);
@@ -649,20 +651,19 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
649651
{
650652
data.SectionContentData = new List<SectionContentTempData>();
651653
}
652-
if (data.SectionContentData != null && data.SectionContentData.Count >= 3)
654+
if (data.EditCourseContent)
653655
{
654656
return RedirectToNextSectionOrSummary(
655657
model.Index,
656-
new SetCourseContentViewModel(data.CourseContentData!)
657-
);
658+
new SetCourseContentViewModel(data.CourseContentData!));
658659
}
659-
data!.SectionContentData!.Add(
660-
new SectionContentTempData(
661-
model.Tutorials != null
662-
? model.Tutorials.Select(GetCourseTutorialData)
663-
: new List<CourseTutorialTempData>()
664-
)
665-
);
660+
data!.SectionContentData!.Add(
661+
new SectionContentTempData(
662+
model.Tutorials != null
663+
? model.Tutorials.Select(GetCourseTutorialData)
664+
: new List<CourseTutorialTempData>()
665+
)
666+
);
666667
multiPageFormService.SetMultiPageFormData(data, MultiPageFormDataFeature.AddNewCourse, TempData);
667668

668669
return RedirectToNextSectionOrSummary(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<dd class="nhsuk-summary-list__actions">
2727
@if (!Model.NoContent)
2828
{
29-
<a asp-action="SetCourseContent">
29+
<a asp-action="SetCourseContent"
30+
asp-route-EditCourseContent="true">
3031
Change<span class="nhsuk-u-visually-hidden"> course content</span>
3132
</a>
3233
}

0 commit comments

Comments
 (0)