mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
can create and drag and drop pages
This commit is contained in:
@@ -6,7 +6,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
public record LocalAssignment
|
||||
public record LocalAssignment: IModuleItem
|
||||
{
|
||||
private string _name = "";
|
||||
public string Name
|
||||
@@ -28,6 +28,7 @@ public record LocalAssignment
|
||||
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
|
||||
public int PointsPossible => Rubric.Sum(r => r.IsExtraCredit ? 0 : r.Points);
|
||||
|
||||
|
||||
public string GetDescriptionHtml()
|
||||
{
|
||||
return Markdig.Markdown.ToHtml(Description);
|
||||
|
||||
9
Management/Models/Local/IModuleItem.cs
Normal file
9
Management/Models/Local/IModuleItem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
public interface IModuleItem
|
||||
{
|
||||
public string Name { get; init; }
|
||||
public DateTime DueAt { get; init; }
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
namespace LocalModels;
|
||||
|
||||
public record LocalCoursePage
|
||||
public record LocalCoursePage: IModuleItem
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
public required string Text { get; set; }
|
||||
public DateTime? DueDateForOrdering { get; init; }
|
||||
public DateTime DueAt { get; init; }
|
||||
|
||||
public string ToMarkdown()
|
||||
{
|
||||
var printableDueDate = DueDateForOrdering.ToString()?.Replace('\u202F', ' ');
|
||||
var printableDueDate = DueAt.ToString()?.Replace('\u202F', ' ');
|
||||
var settingsMarkdown = $"Name: {Name}\n"
|
||||
+ $"DueDateForOrdering: {printableDueDate}\n"
|
||||
+ "---\n";
|
||||
@@ -20,9 +20,9 @@ public record LocalCoursePage
|
||||
var name = MarkdownUtils.ExtractLabelValue(rawSettings, "Name");
|
||||
var rawDate = MarkdownUtils.ExtractLabelValue(rawSettings, "DueDateForOrdering");
|
||||
|
||||
DateTime? parsedDate = DateTime.TryParse(rawDate, out DateTime parsedDueAt)
|
||||
DateTime parsedDate = DateTime.TryParse(rawDate, out DateTime parsedDueAt)
|
||||
? parsedDueAt
|
||||
: null;
|
||||
: throw new LocalPageMarkdownParseException($"could not parse due date: {rawDate}");
|
||||
|
||||
|
||||
var text = pageMarkdown.Split("---\n")[1];
|
||||
@@ -30,7 +30,7 @@ public record LocalCoursePage
|
||||
return new LocalCoursePage
|
||||
{
|
||||
Name = name,
|
||||
DueDateForOrdering = parsedDate,
|
||||
DueAt = parsedDate,
|
||||
Text = text
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
public record LocalQuiz
|
||||
public record LocalQuiz: IModuleItem
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
public required string Description { get; init; }
|
||||
@@ -27,7 +27,7 @@ public record LocalQuiz
|
||||
.CanvasId;
|
||||
|
||||
public string GetDescriptionHtml() => Markdig.Markdown.ToHtml(Description);
|
||||
|
||||
|
||||
public string ToYaml()
|
||||
{
|
||||
var serializer = new SerializerBuilder().DisableAliases().Build();
|
||||
@@ -100,7 +100,7 @@ Description: {Description}
|
||||
|
||||
|
||||
var rawLockAt = extractLabelValue(settings, "LockAt");
|
||||
DateTime? lockAt = DateTime.TryParse(rawLockAt, out DateTime parsedLockAt)
|
||||
DateTime? lockAt = DateTime.TryParse(rawLockAt, out DateTime parsedLockAt)
|
||||
? parsedLockAt
|
||||
: null;
|
||||
|
||||
@@ -153,6 +153,6 @@ public class QuizMarkdownParseException : Exception
|
||||
{
|
||||
public QuizMarkdownParseException(string message): base(message)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user