diff --git a/Management.Test/Markdown/QuizMarkdownTests.cs b/Management.Test/Markdown/QuizMarkdownTests.cs
index 9928fa0..57ba1cd 100644
--- a/Management.Test/Markdown/QuizMarkdownTests.cs
+++ b/Management.Test/Markdown/QuizMarkdownTests.cs
@@ -34,102 +34,7 @@ this is my description in markdown
markdown.Should().Contain("AssignmentGroup: someId");
markdown.Should().Contain("AllowedAttempts: -1");
}
- [Test]
- public void QuzMarkdownIncludesMultipleChoiceQuestion()
- {
- var quiz = new LocalQuiz()
- {
- Name = "Test Quiz",
- Description = "desc",
- LockAt = DateTime.MaxValue,
- DueAt = DateTime.MaxValue,
- ShuffleAnswers = true,
- OneQuestionAtATime = false,
- LocalAssignmentGroupName = "someId",
- AllowedAttempts = -1,
- Questions = new LocalQuizQuestion[]
- {
- new LocalQuizQuestion()
- {
- Id = "someid",
- Points = 2,
- Text = @"`some type` of question
-with many
-
-```
-lines
-```
-",
- QuestionType = QuestionType.MULTIPLE_CHOICE,
- Answers = new LocalQuizQuestionAnswer[]
- {
- new LocalQuizQuestionAnswer() { Correct = true, Text = "true" },
- new LocalQuizQuestionAnswer() { Correct = false, Text = "false" + Environment.NewLine +Environment.NewLine + "endline" },
- }
- }
- }
- };
-
- var markdown = quiz.ToMarkdown();
- var expectedQuestionString = @"
-Points: 2
-`some type` of question
-
-with many
-
-```
-lines
-```
-
-*a) true
-b) false
-
-endline
-";
- markdown.Should().Contain(expectedQuestionString);
- }
-
- [Test]
- public void QuzMarkdownIncludesMultipleAnswerQuestion()
- {
- var quiz = new LocalQuiz()
- {
- Name = "Test Quiz",
- Description = "desc",
- LockAt = DateTime.MaxValue,
- DueAt = DateTime.MaxValue,
- ShuffleAnswers = true,
- OneQuestionAtATime = false,
- LocalAssignmentGroupName = "someId",
- AllowedAttempts = -1,
- Questions = new LocalQuizQuestion[]
- {
- new()
- {
- Id = "somesdid",
- Text = "oneline question",
- Points = 1,
- QuestionType = QuestionType.MULTIPLE_ANSWERS,
- Answers = new LocalQuizQuestionAnswer[]
- {
- new() { Correct = true, Text = "true" },
- new() { Correct = true, Text = "false"},
- new() { Correct = false, Text = "neither"},
- }
- }
- }
- };
- var markdown = quiz.ToMarkdown();
- var expectedQuestionString = @"
-Points: 1
-oneline question
-[*] true
-[*] false
-[ ] neither
-";
- markdown.Should().Contain(expectedQuestionString);
- }
[Test]
public void TestCanParseMarkdownQuizWithNoQuestions()
@@ -199,42 +104,6 @@ b) false
firstQuestion.Answers.ElementAt(1).Text.Should().Contain("endline");
}
- [Test]
- public void CanParseQuestionWithMultipleAnswers()
- {
- 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
----
-Which events are triggered when the user clicks on an input field?
-[*] click
-[*] focus
-[*] mousedown
-[] submit
-[] change
-[] mouseout
-[] keydown
----
-";
-
- var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
- var firstQuestion = quiz.Questions.First();
- firstQuestion.Points.Should().Be(1);
- firstQuestion.QuestionType.Should().Be(QuestionType.MULTIPLE_ANSWERS);
- firstQuestion.Text.Should().Contain("Which events are triggered when the user clicks on an input field?");
- firstQuestion.Answers.First().Text.Should().Be("click");
- firstQuestion.Answers.First().Correct.Should().BeTrue();
- firstQuestion.Answers.ElementAt(3).Correct.Should().BeFalse();
- firstQuestion.Answers.ElementAt(3).Text.Should().Be("submit");
- }
[Test]
public void CanParseMultipleQuestions()
{
@@ -267,56 +136,7 @@ b) false
secondQuestion.Points.Should().Be(2);
secondQuestion.QuestionType.Should().Be(QuestionType.MULTIPLE_CHOICE);
}
- [Test]
- public void CanParseEssay()
- {
- 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
----
-Which events are triggered when the user clicks on an input field?
-essay
-";
- var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
- var firstQuestion = quiz.Questions.First();
- firstQuestion.Points.Should().Be(1);
- firstQuestion.QuestionType.Should().Be(QuestionType.ESSAY);
- firstQuestion.Text.Should().NotContain("essay");
- }
- [Test]
- public void CanParseShortAnswer()
- {
- 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
----
-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(1);
- firstQuestion.QuestionType.Should().Be(QuestionType.SHORT_ANSWER);
- firstQuestion.Text.Should().NotContain("short answer");
- }
[Test]
public void ShortAnswerToMarkdown_IsCorrect()
{
@@ -345,32 +165,156 @@ Which events are triggered when the user clicks on an input field?
short_answer";
questionMarkdown.Should().Contain(expectedMarkdown);
}
+
[Test]
- public void EssayQuestionToMarkdown_IsCorrect()
+ public void SerializationIsDeterministic_EmptyQuiz()
{
- 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
----
-Which events are triggered when the user clicks on an input field?
-essay
-";
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "quiz description",
+ LockAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ DueAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ ShuffleAnswers = true,
+ OneQuestionAtATime = true,
+ LocalAssignmentGroupName = "Assignments"
+ };
+ var quizMarkdown = quiz.ToMarkdown();
- var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
- var firstQuestion = quiz.Questions.First();
+ var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
+ parsedQuiz.Should().BeEquivalentTo(quiz);
+ }
+ [Test]
+ public void SerializationIsDeterministic_ShortAnswer()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "quiz description",
+ LockAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ DueAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ ShuffleAnswers = true,
+ OneQuestionAtATime = true,
+ LocalAssignmentGroupName = "Assignments",
+ Questions = new LocalQuizQuestion[]
+ {
+ new ()
+ {
+ Text = "test short answer",
+ QuestionType = QuestionType.SHORT_ANSWER,
+ Points = 1
+ }
+ }
+ };
+ var quizMarkdown = quiz.ToMarkdown();
- var questionMarkdown = firstQuestion.ToMarkdown();
- var expectedMarkdown = @"Points: 1
-Which events are triggered when the user clicks on an input field?
-essay";
- questionMarkdown.Should().Contain(expectedMarkdown);
+ var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
+ parsedQuiz.Should().BeEquivalentTo(quiz);
+ }
+
+ [Test]
+ public void SerializationIsDeterministic_Essay()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "quiz description",
+ LockAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ DueAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ ShuffleAnswers = true,
+ OneQuestionAtATime = true,
+ LocalAssignmentGroupName = "Assignments",
+ Questions = new LocalQuizQuestion[]
+ {
+ new ()
+ {
+ Text = "test essay",
+ QuestionType = QuestionType.ESSAY,
+ Points = 1
+ }
+ }
+ };
+ var quizMarkdown = quiz.ToMarkdown();
+
+ var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
+ parsedQuiz.Should().BeEquivalentTo(quiz);
+ }
+
+ [Test]
+ public void SerializationIsDeterministic_MultipleAnswer()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "quiz description",
+ LockAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ DueAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ ShuffleAnswers = true,
+ OneQuestionAtATime = true,
+ LocalAssignmentGroupName = "Assignments",
+ Questions = new LocalQuizQuestion[]
+ {
+ new ()
+ {
+ Text = "test multiple answer",
+ QuestionType = QuestionType.MULTIPLE_ANSWERS,
+ Points = 1,
+ Answers = new LocalQuizQuestionAnswer[]
+ {
+ new() {
+ Correct = true,
+ Text="yes",
+ },
+ new() {
+ Correct = true,
+ Text="no",
+ }
+ }
+ }
+ }
+ };
+ var quizMarkdown = quiz.ToMarkdown();
+
+ var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
+ parsedQuiz.Should().BeEquivalentTo(quiz);
+ }
+
+ [Test]
+ public void SerializationIsDeterministic_MultipleChoice()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "quiz description",
+ LockAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ DueAt = new DateTime(2022, 10, 3, 12, 5, 0),
+ ShuffleAnswers = true,
+ OneQuestionAtATime = true,
+ LocalAssignmentGroupName = "Assignments",
+ Questions = new LocalQuizQuestion[]
+ {
+ new ()
+ {
+ Text = "test multiple choice",
+ QuestionType = QuestionType.MULTIPLE_CHOICE,
+ Points = 1,
+ Answers = new LocalQuizQuestionAnswer[]
+ {
+ new() {
+ Correct = true,
+ Text="yes",
+ },
+ new() {
+ Correct = false,
+ Text="no",
+ }
+ }
+ }
+ }
+ };
+ var quizMarkdown = quiz.ToMarkdown();
+
+ var parsedQuiz = LocalQuiz.ParseMarkdown(quizMarkdown);
+ parsedQuiz.Should().BeEquivalentTo(quiz);
}
}
\ No newline at end of file
diff --git a/Management.Test/Markdown/QuizQuestionMarkdownTests.cs b/Management.Test/Markdown/QuizQuestionMarkdownTests.cs
new file mode 100644
index 0000000..59ac971
--- /dev/null
+++ b/Management.Test/Markdown/QuizQuestionMarkdownTests.cs
@@ -0,0 +1,244 @@
+using LocalModels;
+
+public class QuizQuestionMarkdownTests
+{
+ [Test]
+ public void QuzMarkdownIncludesMultipleChoiceQuestion()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "desc",
+ LockAt = DateTime.MaxValue,
+ DueAt = DateTime.MaxValue,
+ ShuffleAnswers = true,
+ OneQuestionAtATime = false,
+ LocalAssignmentGroupName = "someId",
+ AllowedAttempts = -1,
+ Questions = new LocalQuizQuestion[]
+ {
+ new LocalQuizQuestion()
+ {
+ Id = "someid",
+ Points = 2,
+ Text = @"`some type` of question
+
+with many
+
+```
+lines
+```
+",
+ QuestionType = QuestionType.MULTIPLE_CHOICE,
+ Answers = new LocalQuizQuestionAnswer[]
+ {
+ new LocalQuizQuestionAnswer() { Correct = true, Text = "true" },
+ new LocalQuizQuestionAnswer() { Correct = false, Text = "false" + Environment.NewLine +Environment.NewLine + "endline" },
+ }
+ }
+ }
+ };
+
+ var markdown = quiz.ToMarkdown();
+ var expectedQuestionString = @"
+Points: 2
+`some type` of question
+
+with many
+
+```
+lines
+```
+
+*a) true
+b) false
+
+endline
+";
+ markdown.Should().Contain(expectedQuestionString);
+ }
+
+ [Test]
+ public void QuzMarkdownIncludesMultipleAnswerQuestion()
+ {
+ var quiz = new LocalQuiz()
+ {
+ Name = "Test Quiz",
+ Description = "desc",
+ LockAt = DateTime.MaxValue,
+ DueAt = DateTime.MaxValue,
+ ShuffleAnswers = true,
+ OneQuestionAtATime = false,
+ LocalAssignmentGroupName = "someId",
+ AllowedAttempts = -1,
+ Questions = new LocalQuizQuestion[]
+ {
+ new()
+ {
+ Id = "somesdid",
+ Text = "oneline question",
+ Points = 1,
+ QuestionType = QuestionType.MULTIPLE_ANSWERS,
+ Answers = new LocalQuizQuestionAnswer[]
+ {
+ new() { Correct = true, Text = "true" },
+ new() { Correct = true, Text = "false"},
+ new() { Correct = false, Text = "neither"},
+ }
+ }
+ }
+ };
+ var markdown = quiz.ToMarkdown();
+ var expectedQuestionString = @"
+Points: 1
+oneline question
+[*] true
+[*] false
+[ ] neither
+";
+ markdown.Should().Contain(expectedQuestionString);
+ }
+ [Test]
+ public void CanParseQuestionWithMultipleAnswers()
+ {
+ 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
+---
+Which events are triggered when the user clicks on an input field?
+[*] click
+[*] focus
+[*] mousedown
+[] submit
+[] change
+[] mouseout
+[] keydown
+---
+";
+
+ var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
+ var firstQuestion = quiz.Questions.First();
+ firstQuestion.Points.Should().Be(1);
+ firstQuestion.QuestionType.Should().Be(QuestionType.MULTIPLE_ANSWERS);
+ firstQuestion.Text.Should().Contain("Which events are triggered when the user clicks on an input field?");
+ firstQuestion.Answers.First().Text.Should().Be("click");
+ firstQuestion.Answers.First().Correct.Should().BeTrue();
+ firstQuestion.Answers.ElementAt(3).Correct.Should().BeFalse();
+ firstQuestion.Answers.ElementAt(3).Text.Should().Be("submit");
+ }
+
+ [Test]
+ public void CanParseEssay()
+ {
+ 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
+---
+Which events are triggered when the user clicks on an input field?
+essay
+";
+
+ var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
+ var firstQuestion = quiz.Questions.First();
+ firstQuestion.Points.Should().Be(1);
+ firstQuestion.QuestionType.Should().Be(QuestionType.ESSAY);
+ firstQuestion.Text.Should().NotContain("essay");
+ }
+ [Test]
+ public void CanParseShortAnswer()
+ {
+ 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
+---
+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(1);
+ firstQuestion.QuestionType.Should().Be(QuestionType.SHORT_ANSWER);
+ firstQuestion.Text.Should().NotContain("short answer");
+ }
+ [Test]
+ public void ShortAnswerToMarkdown_IsCorrect()
+ {
+ 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
+---
+Which events are triggered when the user clicks on an input field?
+short answer
+";
+
+ var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
+ var firstQuestion = quiz.Questions.First();
+
+ var questionMarkdown = firstQuestion.ToMarkdown();
+ var expectedMarkdown = @"Points: 1
+Which events are triggered when the user clicks on an input field?
+short_answer";
+ questionMarkdown.Should().Contain(expectedMarkdown);
+ }
+ [Test]
+ public void EssayQuestionToMarkdown_IsCorrect()
+ {
+ 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
+---
+Which events are triggered when the user clicks on an input field?
+essay
+";
+
+ var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
+ var firstQuestion = quiz.Questions.First();
+
+ var questionMarkdown = firstQuestion.ToMarkdown();
+ var expectedMarkdown = @"Points: 1
+Which events are triggered when the user clicks on an input field?
+essay";
+ questionMarkdown.Should().Contain(expectedMarkdown);
+ }
+}
\ No newline at end of file
diff --git a/Management.Web/Pages/AssignmentFormPage.razor b/Management.Web/Pages/AssignmentFormPage.razor
index eee966f..a8c69be 100644
--- a/Management.Web/Pages/AssignmentFormPage.razor
+++ b/Management.Web/Pages/AssignmentFormPage.razor
@@ -11,7 +11,7 @@
@using Management.Web.Shared.Module.Assignment
@using Management.Web.Shared.Components
-@inject YamlManager yamlManager
+@inject FileStorageManager fileStorageManager
@inject CanvasService canvas
@inject CoursePlanner planner
@inject AssignmentEditorContext assignmentContext
@@ -23,28 +23,28 @@
[Parameter]
public string? AssignmentId { get; set; } = default!;
- private bool loading { get; set; }= true;
-
+ private bool loading { get; set; } = true;
+
protected override async Task OnInitializedAsync()
{
- if(loading)
+ if (loading)
{
loading = false;
logger.LogInformation($"loading assignment {CourseName} {AssignmentId}");
- if(planner.LocalCourse == null)
+ if (planner.LocalCourse == null)
{
- var courses = await yamlManager.LoadSavedCourses();
+ var courses = await fileStorageManager.LoadSavedCourses();
planner.LocalCourse = courses.First(c => c.Settings.Name == CourseName);
logger.LogInformation($"set course to '{planner.LocalCourse?.Settings.Name}'");
}
- if(assignmentContext.Assignment == null)
+ if (assignmentContext.Assignment == null)
{
var assignment = planner
- .LocalCourse?
- .Modules
- .SelectMany(m => m.Assignments)
- .FirstOrDefault(a => a.Id == AssignmentId);
+ .LocalCourse?
+ .Modules
+ .SelectMany(m => m.Assignments)
+ .FirstOrDefault(a => a.Id == AssignmentId);
assignmentContext.Assignment = assignment;
logger.LogInformation($"set assignment to '{assignmentContext.Assignment?.Name}'");
@@ -56,12 +56,12 @@
}
-@if(loading)
+@if (loading)
{