diff --git a/Management.Web/Pages/Course/Module/ModuleItems/QuizListItem.razor b/Management.Web/Pages/Course/Module/ModuleItems/QuizListItem.razor index a159c91..b0e9f63 100644 --- a/Management.Web/Pages/Course/Module/ModuleItems/QuizListItem.razor +++ b/Management.Web/Pages/Course/Module/ModuleItems/QuizListItem.razor @@ -39,7 +39,7 @@ @onclick="OnClick" role="button" > - + @if(!existsInCanvas) {
diff --git a/Management/Features/Configuration/AssignmentEditorContext.cs b/Management/Features/Configuration/AssignmentEditorContext.cs index 494982f..d33411d 100644 --- a/Management/Features/Configuration/AssignmentEditorContext.cs +++ b/Management/Features/Configuration/AssignmentEditorContext.cs @@ -95,7 +95,7 @@ public class AssignmentEditorContext } // Console.WriteLine(JsonSerializer.Serialize(Assignment.LocalAssignmentGroupName)); // Console.WriteLine(JsonSerializer.Serialize(planner.LocalCourse.Settings.AssignmentGroups)); - + var canvasAssignmentGroupId = Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups); if (canvasAssignmentGroupId == null) @@ -154,12 +154,13 @@ public class AssignmentEditorContext (ulong)courseCanvasId, canvasModule.Id, Assignment.Name, - + "Assignment", createdAssignmentCanvasId ); - await planner.LocalCourse.Modules.First().SortModuleItems( + var module = getCurrentLocalModule(Assignment, planner.LocalCourse); + await module.SortModuleItems( (ulong)courseCanvasId, canvasModule.Id, canvas diff --git a/Management/Features/Configuration/PageEditorContext.cs b/Management/Features/Configuration/PageEditorContext.cs index 8404205..8089478 100644 --- a/Management/Features/Configuration/PageEditorContext.cs +++ b/Management/Features/Configuration/PageEditorContext.cs @@ -121,7 +121,8 @@ public class PageEditorContext( canvasPage ); - await planner.LocalCourse.Modules.First().SortModuleItems( + var currentModule = getCurrentLocalModule(Page, planner.LocalCourse); + await currentModule.SortModuleItems( (ulong)courseCanvasId, canvasModule.Id, canvas diff --git a/Management/Features/Configuration/Synchronization/ModuleSyncronizationExtensions.cs b/Management/Features/Configuration/Synchronization/ModuleSyncronizationExtensions.cs index 4f85190..6b3f69a 100644 --- a/Management/Features/Configuration/Synchronization/ModuleSyncronizationExtensions.cs +++ b/Management/Features/Configuration/Synchronization/ModuleSyncronizationExtensions.cs @@ -40,15 +40,20 @@ public static partial class ModuleSyncronizationExtensions var canvasModuleItems = await canvas.Modules.GetModuleItems(canvasId, moduleCanvasId); var moduleItemsInCorrectOrder = canvasModuleItems .OrderBy(canvasItem => { + if(canvasItem.Type == "Page") { var localPage = localModule.Pages.FirstOrDefault(p => p.Name == canvasItem.Title); + Console.WriteLine(JsonSerializer.Serialize(localModule.Pages)); + if(localPage != null) - return localPage.DueAt; + return localPage.DueAt.Date; } - return canvasItem.ContentDetails?.DueAt; + return canvasItem.ContentDetails?.DueAt?.Date; }) - .Select((a, i) => (Item: a, Position: i + 1)); + .ThenBy(canvasItem => canvasItem.Title) + .Select((a, i) => (Item: a, Position: i + 1)) + .ToArray(); foreach (var (moduleItem, position) in moduleItemsInCorrectOrder) { diff --git a/Management/Services/Canvas/CanvasAssignmentService.cs b/Management/Services/Canvas/CanvasAssignmentService.cs index eaddf3e..89dfc8e 100644 --- a/Management/Services/Canvas/CanvasAssignmentService.cs +++ b/Management/Services/Canvas/CanvasAssignmentService.cs @@ -24,8 +24,8 @@ public class CanvasAssignmentService( assignments => assignments.Select( a => a with { DueAt = a.DueAt?.ToLocalTime(), LockAt = a.LockAt?.ToLocalTime() } - ) - ); + ).ToArray() + ).ToArray(); } public async Task Create( diff --git a/Management/Services/Canvas/CanvasModuleService.cs b/Management/Services/Canvas/CanvasModuleService.cs index 014e187..1b98432 100644 --- a/Management/Services/Canvas/CanvasModuleService.cs +++ b/Management/Services/Canvas/CanvasModuleService.cs @@ -62,7 +62,16 @@ public class CanvasModuleService var (items, response) = await webRequestor.GetAsync>(request); if (items == null) throw new Exception($"Error getting canvas module items for {url}"); - return items; + return items.Select(i => + i with { + ContentDetails = i.ContentDetails == null + ? null + : i.ContentDetails with { + DueAt = i.ContentDetails.DueAt?.ToLocalTime(), + LockAt = i.ContentDetails.LockAt?.ToLocalTime(), + } + } + ); } public async Task>> GetAllModulesItems( @@ -90,4 +99,4 @@ public class CanvasModuleService } return output; } -} \ No newline at end of file +} diff --git a/Management/Services/Canvas/CanvasService.cs b/Management/Services/Canvas/CanvasService.cs index e7fd154..ee637cd 100644 --- a/Management/Services/Canvas/CanvasService.cs +++ b/Management/Services/Canvas/CanvasService.cs @@ -18,7 +18,7 @@ public class CanvasService( CanvasQuizService Quizzes, CanvasCoursePageService Pages, MyLogger logger - ) +) { private readonly IWebRequestor webRequestor = webRequestor; private readonly CanvasServiceUtils utils = utils; diff --git a/build.sh b/build.sh index 4ba4225..d59e6b6 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ MAJOR_VERSION="1" -MINOR_VERSION="4" +MINOR_VERSION="5" VERSION="$MAJOR_VERSION.$MINOR_VERSION" dotnet publish Management.Web/ \ @@ -22,4 +22,4 @@ echo "docker image tag canvas_management:$MAJOR_VERSION alexmickelson/canvas_man echo "docker image tag canvas_management:latest alexmickelson/canvas_management:latest" echo "docker push alexmickelson/canvas_management:$VERSION" echo "docker push alexmickelson/canvas_management:$MAJOR_VERSION" -echo "docker push alexmickelson/canvas_management:latest" \ No newline at end of file +echo "docker push alexmickelson/canvas_management:latest"