module item sorting fixed

This commit is contained in:
2024-01-12 17:02:13 -07:00
parent 324bb94eda
commit b28bea77e9
8 changed files with 31 additions and 15 deletions

View File

@@ -39,7 +39,7 @@
@onclick="OnClick"
role="button"
>
<ModuleItemLayout Name=Quiz.Name IsSyncedWithCanvas=existsInCanvas>
<ModuleItemLayout Name=@Quiz.Name IsSyncedWithCanvas=@existsInCanvas>
@if(!existsInCanvas)
{
<div class="mx-3 text-body-tertiary">

View File

@@ -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

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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<ulong> Create(

View File

@@ -62,7 +62,16 @@ public class CanvasModuleService
var (items, response) = await webRequestor.GetAsync<IEnumerable<CanvasModuleItem>>(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<Dictionary<CanvasModule, IEnumerable<CanvasModuleItem>>> GetAllModulesItems(
@@ -90,4 +99,4 @@ public class CanvasModuleService
}
return output;
}
}
}

View File

@@ -18,7 +18,7 @@ public class CanvasService(
CanvasQuizService Quizzes,
CanvasCoursePageService Pages,
MyLogger<CanvasService> logger
)
)
{
private readonly IWebRequestor webRequestor = webRequestor;
private readonly CanvasServiceUtils utils = utils;

View File

@@ -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"
echo "docker push alexmickelson/canvas_management:latest"