Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,23 @@ private IActionResult SaveSectionAndRedirect(SetSectionContentViewModel model)
{
data.SectionContentData = new List<SectionContentTempData>();
}
if (data.EditCourseContent)
var sectionsToRemove = new List<SectionContentTempData>();
foreach (var section in data.SectionContentData)
{
return RedirectToNextSectionOrSummary(
model.Index,
new SetCourseContentViewModel(data.CourseContentData!));
section.Tutorials = section.Tutorials
.Where(t => !model.Tutorials.Any(newT => newT.TutorialId == t.TutorialId))
.ToList();
if (!section.Tutorials.Any())
{
sectionsToRemove.Add(section);
}
}
if (sectionsToRemove.Count > 0)
{
foreach (var section in sectionsToRemove)
{
data.SectionContentData.Remove(section);
}
}
data!.SectionContentData!.Add(
new SectionContentTempData(
Expand Down Expand Up @@ -732,18 +744,19 @@ private static IEnumerable<CourseStatisticsWithAdminFieldResponseCounts> UpdateC
private IEnumerable<Tutorial> GetTutorialsFromSectionContentData(List<SectionContentTempData> sectionContentData, List<Tutorial> sectionTutorial)
{
if (sectionContentData == null || sectionTutorial == null) return new List<Tutorial>();
var updatedRecords = sectionContentData
.SelectMany(data => data.Tutorials)
.Join(sectionTutorial,
tempData => new { tempData.TutorialId, tempData.TutorialName }, // Match on both TutorialId and TutorialName
index => new { index.TutorialId, index.TutorialName },
(tempData, index) => new Tutorial
var updatedRecords = sectionTutorial
.GroupJoin(
sectionContentData.SelectMany(data => data.Tutorials),
tutorial => new { tutorial.TutorialId, tutorial.TutorialName },
tempData => new { tempData.TutorialId, tempData.TutorialName },
(tutorial, matchingTempData) => new Tutorial
{
TutorialId = index.TutorialId,
TutorialName = index.TutorialName,
Status = tempData.LearningEnabled, // Updated from sectionContentData
DiagStatus = tempData.DiagnosticEnabled // Updated from sectionContentData
})
TutorialId = tutorial.TutorialId,
TutorialName = tutorial.TutorialName,
Status = matchingTempData.Any() ? matchingTempData.First().LearningEnabled : tutorial.Status,
DiagStatus = matchingTempData.Any() ? matchingTempData.First().DiagnosticEnabled : tutorial.DiagStatus
}
)
.ToList();

return updatedRecords;
Expand Down
Loading