Skip to content

Commit 409b1ee

Browse files
TD-5291 Issue on 'Course set up' screen when selected Few course content first time and changed to 'All' of them clicking 'change link'
1 parent 40cfeb7 commit 409b1ee

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,20 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
651651
{
652652
data.SectionContentData = new List<SectionContentTempData>();
653653
}
654-
if (data.EditCourseContent)
654+
var sectionsToRemove = new List<SectionContentTempData>();
655+
foreach (var section in data.SectionContentData)
655656
{
656-
return RedirectToNextSectionOrSummary(
657-
model.Index,
658-
new SetCourseContentViewModel(data.CourseContentData!));
657+
section.Tutorials = section.Tutorials
658+
.Where(t => !model.Tutorials.Any(newT => newT.TutorialId == t.TutorialId))
659+
.ToList();
660+
if (!section.Tutorials.Any())
661+
{
662+
sectionsToRemove.Add(section);
663+
}
664+
}
665+
foreach (var section in sectionsToRemove)
666+
{
667+
data.SectionContentData.Remove(section);
659668
}
660669
data!.SectionContentData!.Add(
661670
new SectionContentTempData(

0 commit comments

Comments
 (0)