diff --git a/Management.Test/Markdown/QuizMarkdownTests.cs b/Management.Test/Markdown/QuizMarkdownTests.cs index b060014..9928fa0 100644 --- a/Management.Test/Markdown/QuizMarkdownTests.cs +++ b/Management.Test/Markdown/QuizMarkdownTests.cs @@ -317,4 +317,60 @@ short answer 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/QuizFormPage.razor b/Management.Web/Pages/QuizFormPage.razor index c14ab24..1eb3c95 100644 --- a/Management.Web/Pages/QuizFormPage.razor +++ b/Management.Web/Pages/QuizFormPage.razor @@ -29,6 +29,18 @@ private bool loading { get; set; }= true; private bool addingQuizToCanvas = false; + protected override void OnInitialized() + { + quizContext.StateHasChanged += reload; + } + private void reload() + { + this.InvokeAsync(this.StateHasChanged); + } + public void Dispose() + { + quizContext.StateHasChanged -= reload; + } protected override async Task OnInitializedAsync() { if(loading) @@ -87,12 +99,22 @@ private CanvasQuiz? quizInCanvas => planner.CanvasQuizzes?.FirstOrDefault(q => q.Title == quizContext.Quiz?.Name); private string canvasQuizUrl => $"https://snow.instructure.com/courses/{planner.LocalCourse?.Settings.CanvasId}/quizzes/{quizInCanvas?.Id}"; + + private int? quizPoints => quizContext.Quiz?.Questions.Sum(q => q.Points); }