Skip to content

Commit 6c2d6e4

Browse files
TD-5292 Issue on 'Course set up' screen when selected Few course content first time and changed to 'All' of them clicking 'change link'
1 parent ec0e37c commit 6c2d6e4

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

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

Lines changed: 21 additions & 8 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);
466+
var models = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials);
467+
return View("AddNewCentreCourse/SetSectionContent", models);
468468
}
469-
else
470-
{
471-
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorials);
469+
var model = new SetSectionContentViewModel(section, sectionIndex, showDiagnostic, tutorial);
472470
return View("AddNewCentreCourse/SetSectionContent", model);
473-
}
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

0 commit comments

Comments
 (0)