mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
new syncronization for quizzes, add only
This commit is contained in:
@@ -23,7 +23,7 @@ this is my description in markdown
|
|||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
OneQuestionAtATime = false,
|
OneQuestionAtATime = false,
|
||||||
LocalAssignmentGroupId = "someId",
|
LocalAssignmentGroupName = "someId",
|
||||||
AllowedAttempts = -1,
|
AllowedAttempts = -1,
|
||||||
Questions = new LocalQuizQuestion[] { }
|
Questions = new LocalQuizQuestion[] { }
|
||||||
};
|
};
|
||||||
@@ -54,7 +54,7 @@ this is my description in markdown
|
|||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
OneQuestionAtATime = false,
|
OneQuestionAtATime = false,
|
||||||
LocalAssignmentGroupId = "someId",
|
LocalAssignmentGroupName = "someId",
|
||||||
AllowedAttempts = -1,
|
AllowedAttempts = -1,
|
||||||
Questions = new LocalQuizQuestion[]
|
Questions = new LocalQuizQuestion[]
|
||||||
{
|
{
|
||||||
@@ -114,7 +114,7 @@ b) false
|
|||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
OneQuestionAtATime = false,
|
OneQuestionAtATime = false,
|
||||||
LocalAssignmentGroupId = "someId",
|
LocalAssignmentGroupName = "someId",
|
||||||
AllowedAttempts = -1,
|
AllowedAttempts = -1,
|
||||||
Questions = new LocalQuizQuestion[]
|
Questions = new LocalQuizQuestion[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -188,7 +188,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col-6">
|
||||||
<textarea
|
<textarea
|
||||||
id="description"
|
id="description"
|
||||||
class="form-control h-100"
|
class="form-control h-100"
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
@oninput="handleNewDescription"
|
@oninput="handleNewDescription"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col" @key="descriptionForPreview">
|
<div class="col-6" @key="descriptionForPreview">
|
||||||
@(preview)
|
@(preview)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -102,6 +102,11 @@
|
|||||||
quizContext.SaveQuiz(newQuiz);
|
quizContext.SaveQuiz(newQuiz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task addToCanvas()
|
||||||
|
{
|
||||||
|
await quizContext.AddQuizToCanvas();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<Modal @ref="modal" OnHide="() => quizContext.Quiz = null" >
|
<Modal @ref="modal" OnHide="() => quizContext.Quiz = null" >
|
||||||
@@ -166,6 +171,13 @@
|
|||||||
<Footer>
|
<Footer>
|
||||||
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirm="deleteQuiz" />
|
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirm="deleteQuiz" />
|
||||||
|
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="btn btn-outline-secondary"
|
||||||
|
@onclick="addToCanvas"
|
||||||
|
>
|
||||||
|
Add to Canvas
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
@onclick="() => modal?.Hide()"
|
@onclick="() => modal?.Hide()"
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class CoursePlanner
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var newModules = await LocalCourse.EnsureAllModulesExistInCanvas(
|
var newModules = await LocalCourse.CreateAllModules(
|
||||||
canvasId,
|
canvasId,
|
||||||
CanvasModules,
|
CanvasModules,
|
||||||
canvas
|
canvas
|
||||||
@@ -163,15 +163,16 @@ public class CoursePlanner
|
|||||||
LocalCourse = LocalCourse with { Modules = newModules };
|
LocalCourse = LocalCourse with { Modules = newModules };
|
||||||
CanvasModules = await canvas.Modules.GetModules(canvasId);
|
CanvasModules = await canvas.Modules.GetModules(canvasId);
|
||||||
|
|
||||||
await LocalCourse.SortCanvasModules(canvasId, CanvasModules, canvas);
|
await LocalCourse.SortCanvasModulesByLocalOrder(canvasId, CanvasModules, canvas);
|
||||||
CanvasModulesItems = await canvas.Modules.GetAllModulesItems(canvasId, CanvasModules);
|
CanvasModulesItems = await canvas.Modules.GetAllModulesItems(canvasId, CanvasModules);
|
||||||
|
|
||||||
LocalCourse = await LocalCourse.SyncModulesWithCanvasData(canvasId, CanvasModules, canvas);
|
LocalCourse = await LocalCourse.GetCanvasIdsForLocalModules(canvasId, canvas);
|
||||||
|
|
||||||
LocalCourse = await LocalCourse.SyncAssignmentsWithCanvas(canvasId, CanvasAssignments, canvas);
|
LocalCourse = await LocalCourse.SyncAssignmentsWithCanvas(canvasId, CanvasAssignments, canvas);
|
||||||
CanvasAssignments = await canvas.Assignments.GetAll(canvasId);
|
CanvasAssignments = await canvas.Assignments.GetAll(canvasId);
|
||||||
|
|
||||||
LocalCourse = await LocalCourse.SyncQuizzesWithCanvas(canvasId, CanvasQuizzes, canvas);
|
CanvasModulesItems = await canvas.Modules.GetAllModulesItems(canvasId, CanvasModules);
|
||||||
|
LocalCourse = await LocalCourse.SyncQuizzesWithCanvas(CanvasQuizzes, canvas);
|
||||||
|
|
||||||
await LocalCourse.SyncModuleItemsWithCanvas(canvasId, CanvasModulesItems, canvas);
|
await LocalCourse.SyncModuleItemsWithCanvas(canvasId, CanvasModulesItems, canvas);
|
||||||
CanvasModulesItems = await canvas.Modules.GetAllModulesItems(canvasId, CanvasModules);
|
CanvasModulesItems = await canvas.Modules.GetAllModulesItems(canvasId, CanvasModules);
|
||||||
@@ -181,6 +182,7 @@ public class CoursePlanner
|
|||||||
Console.WriteLine("done syncing with canvas\n");
|
Console.WriteLine("done syncing with canvas\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
LocalCourse = null;
|
LocalCourse = null;
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
using LocalModels;
|
using LocalModels;
|
||||||
using Management.Planner;
|
using Management.Planner;
|
||||||
|
using Management.Services;
|
||||||
|
using Management.Services.Canvas;
|
||||||
|
|
||||||
public class QuizEditorContext
|
public class QuizEditorContext
|
||||||
{
|
{
|
||||||
public event Action? StateHasChanged;
|
public QuizEditorContext(CoursePlanner planner, CanvasService canvas,
|
||||||
private CoursePlanner planner { get; }
|
MyLogger<CanvasAssignmentService> logger)
|
||||||
|
|
||||||
public QuizEditorContext(CoursePlanner planner)
|
|
||||||
{
|
{
|
||||||
this.planner = planner;
|
this.planner = planner;
|
||||||
|
this.canvas = canvas;
|
||||||
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
public event Action? StateHasChanged;
|
||||||
|
private CoursePlanner planner { get; }
|
||||||
|
private CanvasService canvas { get; }
|
||||||
|
|
||||||
|
|
||||||
private LocalQuiz? _quiz;
|
private LocalQuiz? _quiz;
|
||||||
|
private readonly MyLogger<CanvasAssignmentService> logger;
|
||||||
|
|
||||||
public LocalQuiz? Quiz
|
public LocalQuiz? Quiz
|
||||||
{
|
{
|
||||||
get => _quiz;
|
get => _quiz;
|
||||||
@@ -62,6 +71,49 @@ public class QuizEditorContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task AddQuizToCanvas()
|
||||||
|
{
|
||||||
|
logger.Log("started to add quiz to canvas");
|
||||||
|
if(Quiz == null)
|
||||||
|
{
|
||||||
|
logger.Log("cannot add null quiz to canvas");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await planner.LoadCanvasData();
|
||||||
|
if(planner.CanvasQuizzes == null)
|
||||||
|
{
|
||||||
|
logger.Log("cannot add quiz to canvas, failed to retrieve current quizzes");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(planner.LocalCourse == null)
|
||||||
|
{
|
||||||
|
logger.Log("cannot add quiz to canvas, no course stored in planner");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var updatedQuiz = await planner.LocalCourse.AddQuizToCanvas(Quiz, planner.CanvasQuizzes, canvas);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var courseCanvasId = planner.LocalCourse.Settings.CanvasId;
|
||||||
|
var currentModule = getCurrentModule(Quiz, planner.LocalCourse);
|
||||||
|
|
||||||
|
await canvas.CreateModuleItem(
|
||||||
|
(ulong)courseCanvasId,
|
||||||
|
(ulong)currentModule.CanvasId,
|
||||||
|
updatedQuiz.Name,
|
||||||
|
"Quiz",
|
||||||
|
(ulong)updatedQuiz.CanvasId
|
||||||
|
);
|
||||||
|
|
||||||
|
await planner.LocalCourse.Modules.First().SortModuleItems(
|
||||||
|
(ulong)courseCanvasId,
|
||||||
|
(ulong)currentModule.CanvasId,
|
||||||
|
canvas
|
||||||
|
);
|
||||||
|
logger.Log("added quiz to canvas");
|
||||||
|
}
|
||||||
|
|
||||||
private static LocalModule getCurrentModule(LocalQuiz newQuiz, LocalCourse course)
|
private static LocalModule getCurrentModule(LocalQuiz newQuiz, LocalCourse course)
|
||||||
{
|
{
|
||||||
return course.Modules.First(m => m.Quizzes.Select(q => q.Id).Contains(newQuiz.Id))
|
return course.Modules.First(m => m.Quizzes.Select(q => q.Id).Contains(newQuiz.Id))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Management.Planner;
|
|||||||
|
|
||||||
public static partial class ModuleSyncronizationExtensions
|
public static partial class ModuleSyncronizationExtensions
|
||||||
{
|
{
|
||||||
internal static async Task<IEnumerable<LocalModule>> EnsureAllModulesExistInCanvas(
|
internal static async Task<IEnumerable<LocalModule>> CreateAllModules(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasCourseId,
|
ulong canvasCourseId,
|
||||||
IEnumerable<CanvasModule> canvasModules,
|
IEnumerable<CanvasModule> canvasModules,
|
||||||
@@ -32,7 +32,7 @@ public static partial class ModuleSyncronizationExtensions
|
|||||||
return newModules ?? throw new Exception("Error ensuring all modules exist in canvas");
|
return newModules ?? throw new Exception("Error ensuring all modules exist in canvas");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task SortCanvasModules(
|
internal static async Task SortCanvasModulesByLocalOrder(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasId,
|
ulong canvasId,
|
||||||
IEnumerable<CanvasModule> canvasModules,
|
IEnumerable<CanvasModule> canvasModules,
|
||||||
@@ -53,14 +53,13 @@ public static partial class ModuleSyncronizationExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<LocalCourse> SyncModulesWithCanvasData(
|
internal static async Task<LocalCourse> GetCanvasIdsForLocalModules(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasId,
|
ulong canvasId,
|
||||||
IEnumerable<CanvasModule> canvasModules,
|
|
||||||
CanvasService canvas
|
CanvasService canvas
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
canvasModules = await canvas.Modules.GetModules(canvasId);
|
var canvasModules = await canvas.Modules.GetModules(canvasId);
|
||||||
return localCourse with
|
return localCourse with
|
||||||
{
|
{
|
||||||
Modules = localCourse.Modules.Select(m =>
|
Modules = localCourse.Modules.Select(m =>
|
||||||
@@ -70,35 +69,38 @@ public static partial class ModuleSyncronizationExtensions
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
internal static async Task SortModuleItems(
|
|
||||||
|
public static async Task SortModuleItems(
|
||||||
this LocalModule localModule,
|
this LocalModule localModule,
|
||||||
ulong canvasId,
|
ulong canvasId,
|
||||||
ulong moduleCanvasId,
|
ulong moduleCanvasId,
|
||||||
IEnumerable<CanvasModuleItem> canvasModuleItems,
|
|
||||||
CanvasService canvas
|
CanvasService canvas
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var localItemsWithCorrectOrder = localModule.Assignments
|
|
||||||
.OrderBy(a => a.DueAt)
|
var canvasModuleItems = await canvas.Modules.GetModuleItems(canvasId, moduleCanvasId);
|
||||||
.Select((a, i) => (Assignment: a, Position: i + 1));
|
var moduleItemsInCorrectOrder = canvasModuleItems
|
||||||
|
.OrderBy(i => i.ContentDetails?.DueAt)
|
||||||
|
.Select((a, i) => (Item: a, Position: i + 1));
|
||||||
|
// var localItemsWithCorrectOrder = localModule.Assignments
|
||||||
|
// .OrderBy(a => a.DueAt)
|
||||||
|
// .Select((a, i) => (Assignment: a, Position: i + 1));
|
||||||
|
|
||||||
var canvasContentIdsByCurrentPosition =
|
// var canvasContentIdsByCurrentPosition =
|
||||||
canvasModuleItems.ToDictionary(item => item.Position, item => item.ContentId)
|
// canvasModuleItems.ToDictionary(item => item.Position, item => item.ContentId)
|
||||||
?? new Dictionary<int, ulong?>();
|
// ?? new Dictionary<int, ulong?>();
|
||||||
|
|
||||||
foreach (var (localAssignment, position) in localItemsWithCorrectOrder)
|
foreach (var (moduleItem, position) in moduleItemsInCorrectOrder)
|
||||||
{
|
{
|
||||||
var itemIsInCorrectOrder =
|
var itemIsInCorrectOrder = moduleItem.Position == position;
|
||||||
canvasContentIdsByCurrentPosition.ContainsKey(position)
|
|
||||||
&& canvasContentIdsByCurrentPosition[position] == localAssignment.CanvasId;
|
|
||||||
|
|
||||||
var currentCanvasItem = canvasModuleItems.First(i => i.ContentId == localAssignment.CanvasId);
|
// var currentCanvasItem = canvasModuleItems.First(i => i.ContentId == moduleItem.CanvasId);
|
||||||
if (!itemIsInCorrectOrder)
|
if (!itemIsInCorrectOrder)
|
||||||
{
|
{
|
||||||
await canvas.UpdateModuleItem(
|
await canvas.UpdateModuleItem(
|
||||||
canvasId,
|
canvasId,
|
||||||
moduleCanvasId,
|
moduleCanvasId,
|
||||||
currentCanvasItem with
|
moduleItem with
|
||||||
{
|
{
|
||||||
Position = position
|
Position = position
|
||||||
}
|
}
|
||||||
@@ -182,7 +184,7 @@ public static partial class ModuleSyncronizationExtensions
|
|||||||
? await canvas.Modules.GetModuleItems(canvasId, moduleCanvasId)
|
? await canvas.Modules.GetModuleItems(canvasId, moduleCanvasId)
|
||||||
: canvasModulesItems[moduleCanvasId];
|
: canvasModulesItems[moduleCanvasId];
|
||||||
|
|
||||||
await localModule.SortModuleItems(canvasId, moduleCanvasId, canvasModuleItems, canvas);
|
await localModule.SortModuleItems(canvasId, moduleCanvasId, canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,47 +16,45 @@ public static partial class QuizSyncronizationExtensions
|
|||||||
|
|
||||||
internal static async Task<LocalCourse> SyncQuizzesWithCanvas(
|
internal static async Task<LocalCourse> SyncQuizzesWithCanvas(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasId,
|
|
||||||
IEnumerable<CanvasQuiz> canvasQuizzes,
|
IEnumerable<CanvasQuiz> canvasQuizzes,
|
||||||
CanvasService canvas
|
CanvasService canvas
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var moduleTasks = localCourse.Modules.Select(async m =>
|
return localCourse;
|
||||||
{
|
// var moduleTasks = localCourse.Modules.Select(async m =>
|
||||||
|
// {
|
||||||
|
|
||||||
var quizTasks = m.Quizzes
|
// var quizTasks = m.Quizzes
|
||||||
.Select(
|
// .Select(
|
||||||
async (q) => q.DueAt > DateTime.Now
|
// async (q) => q.DueAt > DateTime.Now
|
||||||
? await localCourse.SyncQuizToCanvas(canvasId, q, canvasQuizzes, canvas)
|
// ? await localCourse.AddQuizToCanvas(q, canvasQuizzes, canvas)
|
||||||
: q
|
// : q
|
||||||
);
|
// );
|
||||||
var quizzes = await Task.WhenAll(quizTasks);
|
// var quizzes = await Task.WhenAll(quizTasks);
|
||||||
return m with { Quizzes = quizzes };
|
// return m with { Quizzes = quizzes };
|
||||||
});
|
// });
|
||||||
|
|
||||||
var modules = await Task.WhenAll(moduleTasks);
|
// var modules = await Task.WhenAll(moduleTasks);
|
||||||
return localCourse with { Modules = modules };
|
// return localCourse with { Modules = modules };
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<LocalQuiz> SyncQuizToCanvas(
|
public static async Task<LocalQuiz> AddQuizToCanvas(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasCourseId,
|
|
||||||
LocalQuiz localQuiz,
|
LocalQuiz localQuiz,
|
||||||
IEnumerable<CanvasQuiz> canvasQuizzes,
|
IEnumerable<CanvasQuiz> canvasQuizzes,
|
||||||
CanvasService canvas
|
CanvasService canvas
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var isCreated = localQuiz.QuizIsCreated(canvasQuizzes);
|
if (localCourse.Settings.CanvasId == null)
|
||||||
var canvasAssignmentGroupId = localQuiz.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
{
|
||||||
// TODO write update
|
Console.WriteLine("Cannot add quiz to canvas without canvas course id");
|
||||||
}
|
return localQuiz;
|
||||||
else
|
|
||||||
{
|
|
||||||
return await canvas.Quizzes.Create(canvasCourseId, localQuiz, canvasAssignmentGroupId);
|
|
||||||
}
|
}
|
||||||
|
ulong courseCanvasId = (ulong)localCourse.Settings.CanvasId;
|
||||||
|
|
||||||
return localQuiz;
|
var canvasAssignmentGroupId = localQuiz.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||||
|
|
||||||
|
var canvasQuizId = await canvas.Quizzes.Create(courseCanvasId, localQuiz, canvasAssignmentGroupId);
|
||||||
|
return localQuiz with { CanvasId = canvasQuizId };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,13 @@ public record CanvasModuleItem(
|
|||||||
// [OptIn]
|
// [OptIn]
|
||||||
[property: JsonPropertyName("completion_requirement")]
|
[property: JsonPropertyName("completion_requirement")]
|
||||||
CanvasCompletionRequirement? CompletionRequirement,
|
CanvasCompletionRequirement? CompletionRequirement,
|
||||||
[property: JsonPropertyName("published")] bool? Published
|
[property: JsonPropertyName("published")] bool? Published,
|
||||||
|
[property: JsonPropertyName("content_details")] CanvasModuleItemContentDetails? ContentDetails
|
||||||
|
);
|
||||||
|
|
||||||
|
public record CanvasModuleItemContentDetails(
|
||||||
|
[property: JsonPropertyName("due_at")] DateTime? DueAt,
|
||||||
|
[property: JsonPropertyName("lock_at")] DateTime? LockAt,
|
||||||
|
[property: JsonPropertyName("points_possible")] double PointsPossible,
|
||||||
|
[property: JsonPropertyName("locked_for_user")] bool LockedForUser
|
||||||
);
|
);
|
||||||
@@ -57,7 +57,7 @@ public class CanvasModuleService
|
|||||||
|
|
||||||
public async Task<IEnumerable<CanvasModuleItem>> GetModuleItems(ulong courseId, ulong moduleId)
|
public async Task<IEnumerable<CanvasModuleItem>> GetModuleItems(ulong courseId, ulong moduleId)
|
||||||
{
|
{
|
||||||
var url = $"courses/{courseId}/modules/{moduleId}/items";
|
var url = $"courses/{courseId}/modules/{moduleId}/items?include[]=content_details";
|
||||||
var request = new RestRequest(url);
|
var request = new RestRequest(url);
|
||||||
var (items, response) = await webRequestor.GetAsync<IEnumerable<CanvasModuleItem>>(request);
|
var (items, response) = await webRequestor.GetAsync<IEnumerable<CanvasModuleItem>>(request);
|
||||||
if (items == null)
|
if (items == null)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class CanvasQuizService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<LocalQuiz> Create(
|
public async Task<ulong> Create(
|
||||||
ulong canvasCourseId,
|
ulong canvasCourseId,
|
||||||
LocalQuiz localQuiz,
|
LocalQuiz localQuiz,
|
||||||
ulong? canvasAssignmentGroupId
|
ulong? canvasAssignmentGroupId
|
||||||
@@ -69,19 +69,15 @@ public class CanvasQuizService
|
|||||||
if (canvasQuiz == null)
|
if (canvasQuiz == null)
|
||||||
throw new Exception("Created canvas quiz was null");
|
throw new Exception("Created canvas quiz was null");
|
||||||
|
|
||||||
var updatedQuiz = localQuiz with { CanvasId = canvasQuiz.Id };
|
await CreateQuizQuestions(canvasCourseId, localQuiz);
|
||||||
var quizWithQuestions = await CreateQuizQuestions(canvasCourseId, updatedQuiz);
|
return canvasQuiz.Id;
|
||||||
|
|
||||||
return quizWithQuestions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<LocalQuiz> CreateQuizQuestions(ulong canvasCourseId, LocalQuiz localQuiz)
|
public async Task CreateQuizQuestions(ulong canvasCourseId, LocalQuiz localQuiz)
|
||||||
{
|
{
|
||||||
var tasks = localQuiz.Questions.Select(createQuestion(canvasCourseId, localQuiz)).ToArray();
|
var tasks = localQuiz.Questions.Select(createQuestion(canvasCourseId, localQuiz)).ToArray();
|
||||||
var updatedQuestions = await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
|
|
||||||
await hackFixRedundantAssignments(canvasCourseId);
|
await hackFixRedundantAssignments(canvasCourseId);
|
||||||
return localQuiz with { Questions = updatedQuestions };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task hackFixRedundantAssignments(ulong canvasCourseId)
|
private async Task hackFixRedundantAssignments(ulong canvasCourseId)
|
||||||
|
|||||||
Reference in New Issue
Block a user