mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
quizzes and assignments support negative and floating point values
This commit is contained in:
@@ -20,7 +20,7 @@ public record LocalAssignment : IModuleItem
|
||||
public string? LocalAssignmentGroupName { get; init; }
|
||||
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 double PointsPossible => Rubric.Sum(r => r.IsExtraCredit ? 0 : r.Points);
|
||||
|
||||
|
||||
public string GetDescriptionHtml()
|
||||
|
||||
@@ -89,12 +89,12 @@ public static class LocalAssignmentMarkdownParser
|
||||
|
||||
private static RubricItem parseIndividualRubricItemMarkdown(string rawMarkdown)
|
||||
{
|
||||
var pointsPattern = @"\s*-\s*(\d+)\s*pt(s)?:";
|
||||
var pointsPattern = @"\s*-\s*(-?\d+(?:\.\d+)?)\s*pt(s)?:";
|
||||
var match = Regex.Match(rawMarkdown, pointsPattern);
|
||||
if (!match.Success)
|
||||
throw new RubricMarkdownParseException($"points not found: {rawMarkdown}");
|
||||
|
||||
var points = int.Parse(match.Groups[1].Value);
|
||||
var points = double.Parse(match.Groups[1].Value);
|
||||
|
||||
var label = string.Join(": ", rawMarkdown.Split(": ").Skip(1));
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@ public record RubricItem
|
||||
{
|
||||
public static readonly string extraCredit = "(Extra Credit) ";
|
||||
public required string Label { get; set; }
|
||||
public required int Points { get; set; }
|
||||
public required double Points { get; set; }
|
||||
public bool IsExtraCredit => Label.Contains(extraCredit.ToLower(), StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user