mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
moved settings into their own object
This commit is contained in:
@@ -9,8 +9,6 @@ public class SemesterPlanner
|
||||
{
|
||||
var monthsInTerm = 1 + ((endDate.Year - startDate.Year) * 12) + endDate.Month - startDate.Month;
|
||||
|
||||
Console.WriteLine(monthsInTerm);
|
||||
|
||||
return Enumerable
|
||||
.Range(0, monthsInTerm)
|
||||
.Select(monthDiff =>
|
||||
|
||||
@@ -37,26 +37,12 @@ public class CoursePlanner
|
||||
StateHasChanged?.Invoke();
|
||||
return;
|
||||
}
|
||||
|
||||
var courseWithSettings = value with
|
||||
{
|
||||
Settings = value.Settings with
|
||||
{
|
||||
AssignmentGroups = value.AssignmentGroups,
|
||||
Name = value.Settings.Name,
|
||||
DaysOfWeek = value.DaysOfWeek,
|
||||
CanvasId = value.Settings.CanvasId,
|
||||
StartDate = value.Settings.StartDate,
|
||||
DefaultDueTime = value.DefaultDueTime,
|
||||
AssignmentTemplates = value.AssignmentTemplates,
|
||||
}
|
||||
};
|
||||
|
||||
var verifiedCourse = courseWithSettings.GeneralCourseCleanup();
|
||||
var verifiedCourse = value.GeneralCourseCleanup();
|
||||
|
||||
_debounceTimer?.Dispose();
|
||||
_debounceTimer = new Timer(
|
||||
async (_) => await saveCourseToFile(courseWithSettings),
|
||||
async (_) => await saveCourseToFile(verifiedCourse),
|
||||
null,
|
||||
_debounceInterval,
|
||||
Timeout.Infinite
|
||||
@@ -160,7 +146,13 @@ public class CoursePlanner
|
||||
|
||||
var newAssignmentGroups = await LocalCourse.EnsureAllAssignmentGroupsExistInCanvas(
|
||||
canvasId, canvasAssignmentGroups, canvas);
|
||||
LocalCourse = LocalCourse with { AssignmentGroups = newAssignmentGroups };
|
||||
LocalCourse = LocalCourse with
|
||||
{
|
||||
Settings = LocalCourse.Settings with
|
||||
{
|
||||
AssignmentGroups = newAssignmentGroups
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var newModules = await LocalCourse.EnsureAllModulesExistInCanvas(
|
||||
|
||||
@@ -61,7 +61,7 @@ public static class CoursePlannerExtensions
|
||||
.ToArray();
|
||||
|
||||
var canvasAssignmentGroupIds = canvasAssignmentGroups.Select(g => g.Id).ToArray();
|
||||
var correctAssignmentGroups = localCourse.AssignmentGroups.Select(
|
||||
var correctAssignmentGroups = localCourse.Settings.AssignmentGroups.Select(
|
||||
g =>
|
||||
{
|
||||
var groupCanvasId = g.CanvasId ?? 0;
|
||||
@@ -74,7 +74,10 @@ public static class CoursePlannerExtensions
|
||||
return localCourse with
|
||||
{
|
||||
Modules = correctedModules,
|
||||
AssignmentGroups = correctAssignmentGroups,
|
||||
Settings = localCourse.Settings with
|
||||
{
|
||||
AssignmentGroups = correctAssignmentGroups,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public static partial class AssignmentGroupSyncronizationExtensions
|
||||
)
|
||||
{
|
||||
var canvasAssignmentGroupIds = canvasAssignmentGroups.Select(g => g.Id).ToArray();
|
||||
var assignmentGroups = await Task.WhenAll((Task<LocalAssignmentGroup>[])localCourse.AssignmentGroups.Select(
|
||||
var assignmentGroups = await Task.WhenAll((Task<LocalAssignmentGroup>[])localCourse.Settings.AssignmentGroups.Select(
|
||||
async assignmentGroup =>
|
||||
{
|
||||
var canvasGroupWithSameName = canvasAssignmentGroups.FirstOrDefault(
|
||||
|
||||
@@ -25,10 +25,10 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
ca => ca.Id == localAssignment.CanvasId
|
||||
);
|
||||
string localHtmlDescription = localAssignment.GetDescriptionHtml(
|
||||
localCourse.AssignmentTemplates
|
||||
localCourse.Settings.AssignmentTemplates
|
||||
);
|
||||
|
||||
var canvasAssignmentGroupId = localAssignment.GetCanvasAssignmentGroupId(localCourse.AssignmentGroups);
|
||||
var canvasAssignmentGroupId = localAssignment.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||
|
||||
return canvasAssignment != null
|
||||
? await updateAssignmentIfNeeded(
|
||||
@@ -55,7 +55,7 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
{
|
||||
var assignmentNeedsUpdates = localAssignment.NeedsUpdates(
|
||||
canvasAssignments,
|
||||
localCourse.AssignmentTemplates,
|
||||
localCourse.Settings.AssignmentTemplates,
|
||||
canvasAssignmentGroupId,
|
||||
quiet: false
|
||||
);
|
||||
|
||||
@@ -43,7 +43,7 @@ public static partial class QuizSyncronizationExtensions
|
||||
)
|
||||
{
|
||||
var isCreated = localQuiz.QuizIsCreated(canvasQuizzes);
|
||||
var canvasAssignmentGroupId = localQuiz.GetCanvasAssignmentGroupId(localCourse.AssignmentGroups);
|
||||
var canvasAssignmentGroupId = localQuiz.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||
if (isCreated)
|
||||
{
|
||||
// TODO write update
|
||||
|
||||
@@ -3,14 +3,6 @@ namespace LocalModels;
|
||||
public record LocalCourse
|
||||
{
|
||||
public IEnumerable<LocalModule> Modules { get; init; } = Enumerable.Empty<LocalModule>();
|
||||
|
||||
public IEnumerable<LocalAssignmentGroup> AssignmentGroups { get; init; } =
|
||||
Enumerable.Empty<LocalAssignmentGroup>();
|
||||
public IEnumerable<DayOfWeek> DaysOfWeek { get; init; } = Enumerable.Empty<DayOfWeek>();
|
||||
public SimpleTimeOnly DefaultDueTime { get; init; } = new SimpleTimeOnly();
|
||||
public IEnumerable<AssignmentTemplate> AssignmentTemplates { get; init; } =
|
||||
Enumerable.Empty<AssignmentTemplate>();
|
||||
|
||||
public LocalCourseSettings Settings { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user