prevent colon from getting in the name and breaking windows machines

This commit is contained in:
2023-12-05 13:16:21 -07:00
parent 430c6fb089
commit 466aa747b6
2 changed files with 20 additions and 14 deletions

View File

@@ -8,8 +8,17 @@ namespace LocalModels;
public record LocalAssignment
{
// public ulong? CanvasId { get; init; } = null;
public string Name { get; init; } = "";
private string _name = "";
public string Name
{
get => _name;
init
{
if (value.Contains(':'))
throw new AssignmentMarkdownParseException("Name cannot contain a ':' character, it breaks windows filesystems " + value);
_name = value;
}
}
public string Description { get; init; } = "";
// public bool LockAtDueDate { get; init; }
public DateTime? LockAt { get; init; }
@@ -18,7 +27,6 @@ public record LocalAssignment
public IEnumerable<string> SubmissionTypes { get; init; } = Array.Empty<string>();
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
public int PointsPossible => Rubric.Sum(r => r.IsExtraCredit ? 0 : r.Points);
public string GetRubricHtml()
{
var output = "<h1>Rubric</h1><pre><code class=\"language-json\">[\n";

View File

@@ -37,8 +37,6 @@ public class CourseMarkdownLoader
throw new LoadCourseFromFileException(errorMessage);
}
LocalCourseSettings settings = await loadCourseSettings(courseDirectory);
var modules = await loadCourseModules(courseDirectory);
@@ -73,7 +71,7 @@ public class CourseMarkdownLoader
modulePaths
.Select(loadModuleFromPath)
);
return modules;
return modules.OrderBy(m => m.Name);
}
private async Task<LocalModule> loadModuleFromPath(string modulePath)