Skip to content

Commit 252a582

Browse files
authored
Merge pull request #3126 from TechnologyEnhancedLearning/Develop/Fixes/TD-5291-Issueon'Coursesetup'screenwhenselectedFewcoursecontentfirsttimeandchangedto'All'ofthemclicking'changelink'
TD-5291 Issue on 'Course set up' screen when selected Few course content first time and changed to 'All' of them clicking 'change link'
2 parents 0879dbf + 25f6523 commit 252a582

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
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(

0 commit comments

Comments
 (0)