mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
removed need for templates in assignment
This commit is contained in:
@@ -24,9 +24,7 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
var canvasAssignment = canvasAssignments.FirstOrDefault(
|
||||
ca => ca.Id == localAssignment.CanvasId
|
||||
);
|
||||
string localHtmlDescription = localAssignment.GetDescriptionHtml(
|
||||
localCourse.Settings.AssignmentTemplates
|
||||
);
|
||||
string localHtmlDescription = localAssignment.GetDescriptionHtml();
|
||||
|
||||
var canvasAssignmentGroupId = localAssignment.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||
|
||||
@@ -55,7 +53,6 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
{
|
||||
var assignmentNeedsUpdates = localAssignment.NeedsUpdates(
|
||||
canvasAssignments,
|
||||
localCourse.Settings.AssignmentTemplates,
|
||||
canvasAssignmentGroupId,
|
||||
quiet: false
|
||||
);
|
||||
@@ -74,7 +71,6 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
public static bool NeedsUpdates(
|
||||
this LocalAssignment localAssignment,
|
||||
IEnumerable<CanvasAssignment> canvasAssignments,
|
||||
IEnumerable<AssignmentTemplate> courseAssignmentTemplates,
|
||||
ulong? canvasAssignmentGroupId,
|
||||
bool quiet = true
|
||||
)
|
||||
@@ -82,7 +78,7 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
var canvasAssignment = canvasAssignments.First(ca => ca.Id == localAssignment.CanvasId);
|
||||
|
||||
var localHtmlDescription = localAssignment
|
||||
.GetDescriptionHtml(courseAssignmentTemplates)
|
||||
.GetDescriptionHtml()
|
||||
.Replace("<hr />", "<hr>")
|
||||
.Replace(">", "")
|
||||
.Replace("<", "")
|
||||
|
||||
@@ -7,7 +7,7 @@ public record RubricItem
|
||||
public static readonly string extraCredit = "(Extra Credit) ";
|
||||
public string Label { get; set; } = "";
|
||||
public int Points { get; set; } = 0;
|
||||
public bool IsExtraCredit => Label.Contains(extraCredit);
|
||||
public bool IsExtraCredit => Label.Contains(extraCredit.ToLower(), StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static class SubmissionType
|
||||
@@ -42,10 +42,6 @@ public record LocalAssignment
|
||||
public ulong? CanvasId { get; init; } = null;
|
||||
public string Name { get; init; } = "";
|
||||
public string Description { get; init; } = "";
|
||||
// public bool UseTemplate { get; init; } = false;
|
||||
public string? TemplateId { get; init; } = string.Empty;
|
||||
public Dictionary<string, string> TemplateVariables { get; init; } =
|
||||
new Dictionary<string, string>();
|
||||
public bool LockAtDueDate { get; init; }
|
||||
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
|
||||
public DateTime? LockAt { get; init; }
|
||||
@@ -66,28 +62,10 @@ public record LocalAssignment
|
||||
return output;
|
||||
}
|
||||
|
||||
public string GetDescriptionHtml(IEnumerable<AssignmentTemplate>? templates)
|
||||
public string GetDescriptionHtml()
|
||||
{
|
||||
if (TemplateId != null && TemplateId != "" && templates == null)
|
||||
throw new Exception("cannot get description for assignment if templates not provided");
|
||||
|
||||
var rubricHtml = GetRubricHtml();
|
||||
|
||||
if (TemplateId != null && TemplateId != "")
|
||||
{
|
||||
var template =
|
||||
(templates?.FirstOrDefault(t => t.Id == TemplateId))
|
||||
?? throw new Exception($"Could not find template with id {TemplateId}");
|
||||
|
||||
var html = Markdig.Markdown.ToHtml(template.Markdown);
|
||||
|
||||
foreach (KeyValuePair<string, string> entry in TemplateVariables)
|
||||
{
|
||||
html = html.Replace($"%7B%7B{entry.Key}%7D%7D", entry.Value);
|
||||
}
|
||||
return html + "<hr>" + rubricHtml;
|
||||
}
|
||||
|
||||
return Markdig.Markdown.ToHtml(Description) + "<hr>" + rubricHtml;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user