mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
got tests working without quiz id
This commit is contained in:
@@ -137,26 +137,6 @@ public static partial class ModuleSyncronizationExtensions
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var localQuiz in localModule.Quizzes.Where(q => q.DueAt > DateTime.Now))
|
||||
{
|
||||
|
||||
var canvasModuleItemContentIds = canvasModulesItems[moduleCanvasId].Select(i => i.ContentId);
|
||||
if (!canvasModuleItemContentIds.Contains(localQuiz.CanvasId))
|
||||
{
|
||||
var canvasAssignmentId =
|
||||
localQuiz.CanvasId
|
||||
?? throw new Exception("cannot create module item if quiz does not have canvas id");
|
||||
await canvas.CreateModuleItem(
|
||||
canvasId,
|
||||
moduleCanvasId,
|
||||
localQuiz.Name,
|
||||
"Quiz",
|
||||
canvasAssignmentId
|
||||
);
|
||||
anyUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
return anyUpdated;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ public static partial class QuizSyncronizationExtensions
|
||||
{
|
||||
public static bool QuizIsCreated(this LocalQuiz localQuiz, IEnumerable<CanvasQuiz> canvasQuizzes)
|
||||
{
|
||||
return canvasQuizzes.Any(q => q.Id == localQuiz.CanvasId);
|
||||
return canvasQuizzes.Any(q => q.Title == localQuiz.Name);
|
||||
}
|
||||
|
||||
public static async Task<LocalQuiz> AddQuizToCanvas(
|
||||
public static async Task<ulong?> AddQuizToCanvas(
|
||||
this LocalCourse localCourse,
|
||||
LocalQuiz localQuiz,
|
||||
CanvasService canvas
|
||||
@@ -23,13 +23,13 @@ public static partial class QuizSyncronizationExtensions
|
||||
if (localCourse.Settings.CanvasId == null)
|
||||
{
|
||||
Console.WriteLine("Cannot add quiz to canvas without canvas course id");
|
||||
return localQuiz;
|
||||
return null;
|
||||
}
|
||||
ulong courseCanvasId = (ulong)localCourse.Settings.CanvasId;
|
||||
|
||||
var canvasAssignmentGroupId = localQuiz.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||
|
||||
var canvasQuizId = await canvas.Quizzes.Create(courseCanvasId, localQuiz, canvasAssignmentGroupId);
|
||||
return localQuiz with { CanvasId = canvasQuizId };
|
||||
return canvasQuizId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user