quizzes and assignments support negative and floating point values

This commit is contained in:
2024-03-26 14:35:22 -06:00
parent 6a2c4a5673
commit 035c46b284
11 changed files with 112 additions and 35 deletions

View File

@@ -220,4 +220,52 @@ Which events are triggered when the user clicks on an input field?
short_answer";
questionMarkdown.Should().Contain(expectedMarkdown);
}
[Test]
public void NegativePoints_IsAllowed()
{
var rawMarkdownQuiz = @"
Name: Test Quiz
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
LockAt: 2023-08-21T23:59:00
AssignmentGroup: Assignments
AllowedAttempts: -1
Description: this is the
multi line
description
---
Points: -4
Which events are triggered when the user clicks on an input field?
short answer
";
var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
var firstQuestion = quiz.Questions.First();
firstQuestion.Points.Should().Be(-4);
}
[Test]
public void FloatingPointPoints_IsAllowed()
{
var rawMarkdownQuiz = @"
Name: Test Quiz
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
LockAt: 2023-08-21T23:59:00
AssignmentGroup: Assignments
AllowedAttempts: -1
Description: this is the
multi line
description
---
Points: 4.56
Which events are triggered when the user clicks on an input field?
short answer
";
var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
var firstQuestion = quiz.Questions.First();
firstQuestion.Points.Should().Be(4.56);
}
}

View File

@@ -68,4 +68,35 @@ public class RubricMarkdownTests
rubric.First().IsExtraCredit.Should().BeTrue();
rubric.First().Label.Should().Be("(Extra Credit) this is the task");
}
[Test]
public void TestCanParseFloatingPointNubmers()
{
var rawRubric = @"
- 1.5pt: this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().Points.Should().Be(1.5);
}
[Test]
public void TestCanParseNegativeNubmers()
{
var rawRubric = @"
- -2pt: this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().Points.Should().Be(-2.0);
}
[Test]
public void TestCanParseNegativeFloatingPointNubmers()
{
var rawRubric = @"
- -2895.00053pt: this is the task
";
var rubric = LocalAssignment.ParseRubricMarkdown(rawRubric);
rubric.First().Points.Should().Be(-2895.00053);
}
}