mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
more html comparisons
This commit is contained in:
@@ -50,6 +50,16 @@
|
|||||||
assignmentContext.Assignment = Assignment;
|
assignmentContext.Assignment = Assignment;
|
||||||
Navigation.NavigateTo("/course/" + planner.LocalCourse?.Settings.Name + "/assignment/" + Assignment.Name);
|
Navigation.NavigateTo("/course/" + planner.LocalCourse?.Settings.Name + "/assignment/" + Assignment.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool NeedsToBeUpdatedInCanvas => planner.LocalCourse != null
|
||||||
|
&& planner.LocalCourse.Settings.CanvasId != null
|
||||||
|
&& planner.CanvasAssignments != null
|
||||||
|
&& planner.CanvasModules != null
|
||||||
|
&& assignmentInCanvas != null
|
||||||
|
&& Assignment.NeedsUpdates(
|
||||||
|
(CanvasAssignment)assignmentInCanvas,
|
||||||
|
Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -71,16 +81,7 @@
|
|||||||
<div class="col-2 col-lg-1 text-end">
|
<div class="col-2 col-lg-1 text-end">
|
||||||
@if(isSyncedWithCanvas)
|
@if(isSyncedWithCanvas)
|
||||||
{
|
{
|
||||||
@if(planner.LocalCourse != null
|
@if(NeedsToBeUpdatedInCanvas)
|
||||||
&& planner.LocalCourse.Settings.CanvasId != null
|
|
||||||
&& planner.CanvasAssignments != null
|
|
||||||
&& planner.CanvasModules != null
|
|
||||||
&& assignmentInCanvas != null
|
|
||||||
&& Assignment.NeedsUpdates(
|
|
||||||
(CanvasAssignment)assignmentInCanvas,
|
|
||||||
Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
<SyncIcon />
|
<SyncIcon />
|
||||||
}
|
}
|
||||||
@@ -97,6 +98,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if(isSyncedWithCanvas && NeedsToBeUpdatedInCanvas)
|
||||||
|
{
|
||||||
|
<div class="mx-3 text-body-tertiary">
|
||||||
|
@Assignment.GetUpdateReason(
|
||||||
|
(CanvasAssignment)assignmentInCanvas,
|
||||||
|
Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups))
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@if(!showAll)
|
@if(!showAll)
|
||||||
{
|
{
|
||||||
<div class="card-text overflow-hidden p-2" style="max-height: 5rem;">
|
<div class="card-text overflow-hidden p-2" style="max-height: 5rem;">
|
||||||
|
|||||||
@@ -93,11 +93,13 @@ public class AssignmentEditorContext
|
|||||||
logger.Log("cannot update assignment in canvas, could not find canvas assignment with id: " + canvasAssignmentId);
|
logger.Log("cannot update assignment in canvas, could not find canvas assignment with id: " + canvasAssignmentId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Console.WriteLine(JsonSerializer.Serialize(Assignment.LocalAssignmentGroupName));
|
||||||
|
// Console.WriteLine(JsonSerializer.Serialize(planner.LocalCourse.Settings.AssignmentGroups));
|
||||||
|
|
||||||
var canvasAssignmentGroupId = Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups);
|
var canvasAssignmentGroupId = Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups);
|
||||||
|
|
||||||
if (canvasAssignmentGroupId == null)
|
if (canvasAssignmentGroupId == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
logger.Log("cannot update assignment in canvas, could not get assignment group id: " + assignmentInCanvas.AssignmentGroupId);
|
logger.Log("cannot update assignment in canvas, could not get assignment group id: " + assignmentInCanvas.AssignmentGroupId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,5 +162,17 @@ public class CoursePlanner
|
|||||||
CanvasAssignmentGroups = await canvas.AssignmentGroups.GetAll(canvasCourseId);
|
CanvasAssignmentGroups = await canvas.AssignmentGroups.GetAll(canvasCourseId);
|
||||||
|
|
||||||
await LocalCourse.EnsureAllAssignmentGroupsExistInCanvas(canvasCourseId, CanvasAssignmentGroups, canvas);
|
await LocalCourse.EnsureAllAssignmentGroupsExistInCanvas(canvasCourseId, CanvasAssignmentGroups, canvas);
|
||||||
|
|
||||||
|
CanvasAssignmentGroups = await canvas.AssignmentGroups.GetAll(canvasCourseId);
|
||||||
|
|
||||||
|
LocalCourse = LocalCourse with {Settings = LocalCourse.Settings with {
|
||||||
|
AssignmentGroups = LocalCourse.Settings.AssignmentGroups.Select(g => {
|
||||||
|
var canvasGroup = CanvasAssignmentGroups.FirstOrDefault(c => c.Name == g.Name);
|
||||||
|
return canvasGroup == null
|
||||||
|
? g
|
||||||
|
: g with {CanvasId = canvasGroup.Id};
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Net.Quic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using CanvasModel.Assignments;
|
using CanvasModel.Assignments;
|
||||||
@@ -5,13 +6,12 @@ using CanvasModel.Modules;
|
|||||||
using CanvasModel.Quizzes;
|
using CanvasModel.Quizzes;
|
||||||
using LocalModels;
|
using LocalModels;
|
||||||
using Management.Services.Canvas;
|
using Management.Services.Canvas;
|
||||||
|
using Markdig.Renderers.Normalize;
|
||||||
|
|
||||||
namespace Management.Planner;
|
namespace Management.Planner;
|
||||||
|
|
||||||
public static partial class AssignmentSyncronizationExtensions
|
public static partial class AssignmentSyncronizationExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
internal static async Task<ulong> SyncAssignmentToCanvas(
|
internal static async Task<ulong> SyncAssignmentToCanvas(
|
||||||
this LocalCourse localCourse,
|
this LocalCourse localCourse,
|
||||||
ulong canvasCourseId,
|
ulong canvasCourseId,
|
||||||
@@ -20,7 +20,6 @@ public static partial class AssignmentSyncronizationExtensions
|
|||||||
CanvasService canvas
|
CanvasService canvas
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
var canvasAssignment = canvasAssignments.FirstOrDefault(
|
var canvasAssignment = canvasAssignments.FirstOrDefault(
|
||||||
ca => ca.Name == localAssignment.Name
|
ca => ca.Name == localAssignment.Name
|
||||||
);
|
);
|
||||||
@@ -48,7 +47,6 @@ public static partial class AssignmentSyncronizationExtensions
|
|||||||
ulong? canvasAssignmentGroupId
|
ulong? canvasAssignmentGroupId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
var assignmentNeedsUpdates = localAssignment.NeedsUpdates(
|
var assignmentNeedsUpdates = localAssignment.NeedsUpdates(
|
||||||
canvasAssignment,
|
canvasAssignment,
|
||||||
canvasAssignmentGroupId,
|
canvasAssignmentGroupId,
|
||||||
@@ -72,35 +70,24 @@ public static partial class AssignmentSyncronizationExtensions
|
|||||||
ulong? canvasAssignmentGroupId,
|
ulong? canvasAssignmentGroupId,
|
||||||
bool quiet = true
|
bool quiet = true
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
var reason = localAssignment.GetUpdateReason(canvasAssignment, canvasAssignmentGroupId, quiet);
|
||||||
|
return reason != string.Empty;
|
||||||
|
}
|
||||||
|
public static string GetUpdateReason(
|
||||||
|
this LocalAssignment localAssignment,
|
||||||
|
CanvasAssignment canvasAssignment,
|
||||||
|
ulong? canvasAssignmentGroupId,
|
||||||
|
bool quiet = false
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
var localHtmlDescription = localAssignment
|
var localHtmlDescription = removeHtmlDetails(localAssignment.GetDescriptionHtml());
|
||||||
.GetDescriptionHtml()
|
|
||||||
.Replace("<hr />", "<hr>") // self closing tags are hard
|
|
||||||
.Replace("<br />", "<br>")
|
|
||||||
.Replace(">", "")
|
|
||||||
.Replace("<", "")
|
|
||||||
.Replace(">", "")
|
|
||||||
.Replace("<", "")
|
|
||||||
.Replace(""", "")
|
|
||||||
.Replace("\"", "")
|
|
||||||
.Replace("&", "")
|
|
||||||
.Replace("&", "");
|
|
||||||
|
|
||||||
var canvasHtmlDescription = canvasAssignment.Description;
|
var canvasHtmlDescription = canvasAssignment.Description;
|
||||||
canvasHtmlDescription = CanvasScriptTagRegex().Replace(canvasHtmlDescription, "");
|
canvasHtmlDescription = CanvasScriptTagRegex().Replace(canvasHtmlDescription, "");
|
||||||
canvasHtmlDescription = CanvasLinkTagRegex().Replace(canvasHtmlDescription, "");
|
canvasHtmlDescription = CanvasLinkTagRegex().Replace(canvasHtmlDescription, "");
|
||||||
canvasHtmlDescription = canvasHtmlDescription
|
canvasHtmlDescription = removeHtmlDetails(canvasHtmlDescription);
|
||||||
.Replace("<hr />", "<hr>")
|
|
||||||
.Replace("<br />", "<br>")
|
|
||||||
.Replace(">", "")
|
|
||||||
.Replace("<", "")
|
|
||||||
.Replace(">", "")
|
|
||||||
.Replace("<", "")
|
|
||||||
.Replace(""", "")
|
|
||||||
.Replace("\"", "")
|
|
||||||
.Replace("&", "")
|
|
||||||
.Replace("&", "");
|
|
||||||
|
|
||||||
var canvasComparisonDueDate =
|
var canvasComparisonDueDate =
|
||||||
canvasAssignment.DueAt != null
|
canvasAssignment.DueAt != null
|
||||||
@@ -162,36 +149,44 @@ public static partial class AssignmentSyncronizationExtensions
|
|||||||
canvasAssignmentGroupId != null
|
canvasAssignmentGroupId != null
|
||||||
&& canvasAssignmentGroupId == canvasAssignment.AssignmentGroupId;
|
&& canvasAssignmentGroupId == canvasAssignment.AssignmentGroupId;
|
||||||
|
|
||||||
if (!quiet)
|
var reason = "";
|
||||||
{
|
|
||||||
if (!dueDatesSame)
|
if (!dueDatesSame)
|
||||||
|
{
|
||||||
|
reason = $"Due dates different for assignment {localAssignment.Name}, local: {localAssignment.DueAt}, in canvas {canvasAssignment.DueAt}";
|
||||||
|
if (!quiet)
|
||||||
{
|
{
|
||||||
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment));
|
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment));
|
||||||
Console.WriteLine(canvasComparisonDueDate);
|
Console.WriteLine(canvasComparisonDueDate);
|
||||||
Console.WriteLine(localComparisonDueDate);
|
Console.WriteLine(localComparisonDueDate);
|
||||||
Console.WriteLine(
|
Console.WriteLine(reason);
|
||||||
$"Due dates different for assignment {localAssignment.Name}, local: {localAssignment.DueAt}, in canvas {canvasAssignment.DueAt}"
|
|
||||||
);
|
|
||||||
Console.WriteLine(JsonSerializer.Serialize(localAssignment.DueAt));
|
Console.WriteLine(JsonSerializer.Serialize(localAssignment.DueAt));
|
||||||
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment.DueAt));
|
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment.DueAt));
|
||||||
}
|
}
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lockDatesSame)
|
if (!lockDatesSame)
|
||||||
|
{
|
||||||
|
reason = $"Lock dates different for assignment {localAssignment.Name}, local: {localAssignment.LockAt}, in canvas {canvasAssignment.LockAt}";
|
||||||
|
if (!quiet)
|
||||||
{
|
{
|
||||||
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment));
|
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment));
|
||||||
Console.WriteLine(canvasComparisonLockDate);
|
Console.WriteLine(canvasComparisonLockDate);
|
||||||
Console.WriteLine(localComparisonLockDate);
|
Console.WriteLine(localComparisonLockDate);
|
||||||
Console.WriteLine(
|
Console.WriteLine(reason);
|
||||||
$"Lock dates different for assignment {localAssignment.Name}, local: {localAssignment.LockAt}, in canvas {canvasAssignment.LockAt}"
|
|
||||||
);
|
|
||||||
Console.WriteLine(JsonSerializer.Serialize(localAssignment.LockAt));
|
Console.WriteLine(JsonSerializer.Serialize(localAssignment.LockAt));
|
||||||
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment.LockAt));
|
Console.WriteLine(JsonSerializer.Serialize(canvasAssignment.LockAt));
|
||||||
}
|
}
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
if (!descriptionSame)
|
if (!descriptionSame)
|
||||||
|
{
|
||||||
|
reason = $"descriptions different for {localAssignment.Name}";
|
||||||
|
if (!quiet)
|
||||||
{
|
{
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine($"descriptions different for {localAssignment.Name}");
|
Console.WriteLine(reason);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
Console.WriteLine("Local Description:");
|
Console.WriteLine("Local Description:");
|
||||||
@@ -204,34 +199,54 @@ public static partial class AssignmentSyncronizationExtensions
|
|||||||
Console.WriteLine(canvasAssignment.Description);
|
Console.WriteLine(canvasAssignment.Description);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
}
|
}
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
if (!nameSame)
|
if (!nameSame)
|
||||||
Console.WriteLine(
|
{
|
||||||
$"names different for {localAssignment.Name}, local: {localAssignment.Name}, in canvas {canvasAssignment.Name}"
|
reason = $"names different for {localAssignment.Name}, local: {localAssignment.Name}, in canvas {canvasAssignment.Name}";
|
||||||
);
|
if (!quiet)
|
||||||
|
Console.WriteLine(reason);
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
if (!pointsSame)
|
if (!pointsSame)
|
||||||
Console.WriteLine(
|
{
|
||||||
$"Points different for {localAssignment.Name}, local: {localAssignment.PointsPossible}, in canvas {canvasAssignment.PointsPossible}"
|
reason = $"Points different for {localAssignment.Name}, local: {localAssignment.PointsPossible}, in canvas {canvasAssignment.PointsPossible}";
|
||||||
);
|
if (!quiet)
|
||||||
|
Console.WriteLine(reason);
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
if (!submissionTypesSame)
|
if (!submissionTypesSame)
|
||||||
Console.WriteLine(
|
{
|
||||||
$"Submission Types different for {localAssignment.Name}, local: {JsonSerializer.Serialize(localAssignment.SubmissionTypes.Select(t => t.ToString()))}, in canvas {JsonSerializer.Serialize(canvasAssignment.SubmissionTypes)}"
|
reason = $"Submission Types different for {localAssignment.Name}, local: {JsonSerializer.Serialize(localAssignment.SubmissionTypes.Select(t => t.ToString()))}, in canvas {JsonSerializer.Serialize(canvasAssignment.SubmissionTypes)}";
|
||||||
);
|
if (!quiet)
|
||||||
|
Console.WriteLine(reason);
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
if (!assignmentGroupSame)
|
if (!assignmentGroupSame)
|
||||||
Console.WriteLine(
|
{
|
||||||
$"Canvas assignment group ids different for {localAssignment.Name}, local: {canvasAssignmentGroupId}, in canvas {canvasAssignment.AssignmentGroupId}"
|
reason = $"Canvas assignment group ids different for {localAssignment.Name}, local: {canvasAssignmentGroupId}, in canvas {canvasAssignment.AssignmentGroupId}";
|
||||||
);
|
if (!quiet)
|
||||||
|
Console.WriteLine(reason);
|
||||||
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !nameSame
|
return reason;
|
||||||
|| !dueDatesSame
|
|
||||||
|| !lockDatesSame
|
|
||||||
|| !descriptionSame
|
|
||||||
|| !pointsSame
|
|
||||||
|| !submissionTypesSame
|
|
||||||
|| !assignmentGroupSame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string removeHtmlDetails(string canvasHtmlDescription) => canvasHtmlDescription
|
||||||
|
.Replace("<hr />", "<hr>")
|
||||||
|
.Replace("<br />", "<br>")
|
||||||
|
.Replace("<br/>", "<br>")
|
||||||
|
.Replace("<hr/>", "<hr>")
|
||||||
|
.Replace(">", "")
|
||||||
|
.Replace("<", "")
|
||||||
|
.Replace(">", "")
|
||||||
|
.Replace("<", "")
|
||||||
|
.Replace(""", "")
|
||||||
|
.Replace("\"", "")
|
||||||
|
.Replace("&", "")
|
||||||
|
.Replace("&", "");
|
||||||
|
|
||||||
[GeneratedRegex("<script.*script>")]
|
[GeneratedRegex("<script.*script>")]
|
||||||
private static partial Regex CanvasScriptTagRegex();
|
private static partial Regex CanvasScriptTagRegex();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public record LocalAssignment
|
|||||||
public string GetRubricHtml()
|
public string GetRubricHtml()
|
||||||
{
|
{
|
||||||
var output = "<h2>Rubric</h2>";
|
var output = "<h2>Rubric</h2>";
|
||||||
|
|
||||||
var lineStrings = Rubric.Select(
|
var lineStrings = Rubric.Select(
|
||||||
item => $"- {item.Points}pts: {item.Label} <br/>"
|
item => $"- {item.Points}pts: {item.Label} <br/>"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class CanvasAssignmentService
|
|||||||
points_possible = localAssignment.PointsPossible,
|
points_possible = localAssignment.PointsPossible,
|
||||||
assignment_group_id = canvasAssignmentGroupId,
|
assignment_group_id = canvasAssignmentGroupId,
|
||||||
};
|
};
|
||||||
|
|
||||||
var bodyObj = new { assignment = body };
|
var bodyObj = new { assignment = body };
|
||||||
request.AddBody(bodyObj);
|
request.AddBody(bodyObj);
|
||||||
|
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -42,3 +42,23 @@ AssignmentGroupName: Final Project
|
|||||||
SubmissionTypes:
|
SubmissionTypes:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Local Description:
|
||||||
|
pMake a new C# console program./p
|
||||||
|
pAdd functionality to your program to ask the user three different questions and include their responses in a message back to the user. For example, ask the user their name then ask their age then ask their favorite food. Then tell the user Your name is {name}, your age is {age}, and you like to eat {favoriteFood}./p
|
||||||
|
pSubmit a copy of your code via canvas./p
|
||||||
|
hrh2Rubric/h2- 7pts: code submitted and correctly runs br/
|
||||||
|
|
||||||
|
Canvas Description:
|
||||||
|
pMake a new C# console program./p
|
||||||
|
pAdd functionality to your program to ask the user three different questions and include their responses in a message back to the user. For example, ask the user their name then ask their age then ask their favorite food. Then tell the user Your name is {name}, your age is {age}, and you like to eat {favoriteFood}./p
|
||||||
|
pSubmit a copy of your code via canvas./p
|
||||||
|
hrh2Rubric/h2- 7pts: code submitted and correctly runs br
|
||||||
|
|
||||||
|
Canvas Raw Description:
|
||||||
|
<link rel="stylesheet" href="https://instructure-uploads-2.s3.amazonaws.com/account_20000000000010/attachments/118917933/canvas_global_app.css"><p>Make a new C# console program.</p>
|
||||||
|
<p>Add functionality to your program to ask the user three different questions and include their responses in a message back to the user. For example, ask the user their name then ask their age then ask their favorite food. Then tell the user "Your name is {name}, your age is {age}, and you like to eat {favoriteFood}".</p>
|
||||||
|
<p>Submit a copy of your code via canvas.</p>
|
||||||
|
<hr><h2>Rubric</h2>- 7pts: code submitted and correctly runs <br><script src="https://instructure-uploads-2.s3.amazonaws.com/account_20000000000010/attachments/152669279/Canvas_Theme_Sept_2023.js"></script>
|
||||||
Reference in New Issue
Block a user