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); }
+
+ +

@quizContext.Quiz?.Name @@ -107,7 +129,7 @@ }

- Points: @quizContext.Quiz?.Questions.Sum(q => q.Points) + Points: @quizPoints

@if(quizInCanvas != null) { diff --git a/Management.Web/Shared/Components/Forms/ButtonSelect.razor b/Management.Web/Shared/Components/Forms/ButtonSelect.razor index 1363d21..4f978f2 100644 --- a/Management.Web/Shared/Components/Forms/ButtonSelect.razor +++ b/Management.Web/Shared/Components/Forms/ButtonSelect.razor @@ -12,7 +12,7 @@ [Parameter, EditorRequired] public Action OnSelect { get; set; } = default!; - [Parameter, EditorRequired] + [Parameter] public T? SelectedOption { get; set; } private string htmlLabel => Label.Replace("-", ""); diff --git a/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor b/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor index e12331c..47d3840 100644 --- a/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor +++ b/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor @@ -84,12 +84,15 @@ essay --- points: 4 this is a short answer question -short_answer"; +short_answer +--- +points: 4 +the underscore is optional +short answer"; }
-
@if(showHelp) { diff --git a/Management.Web/Shared/Module/NewQuiz.razor b/Management.Web/Shared/Module/NewQuiz.razor index 60e48f9..fd1fb73 100644 --- a/Management.Web/Shared/Module/NewQuiz.razor +++ b/Management.Web/Shared/Module/NewQuiz.razor @@ -1,4 +1,5 @@ @using Management.Web.Shared.Components +@using Management.Web.Shared.Components.Forms @inject CoursePlanner planner @code { @@ -16,10 +17,18 @@ private void submitHandler() { Console.WriteLine("new quiz"); + Console.WriteLine(selectedAssignmentGroup); + if(Name.Trim() == string.Empty) + { + return; + } + + var newQuiz = new LocalQuiz { Name=Name, Description = "", + LocalAssignmentGroupName = selectedAssignmentGroup?.Name, }; if(planner.LocalCourse != null) { @@ -38,6 +47,13 @@ } modal?.Hide(); } + + + private void setAssignmentGroup(LocalAssignmentGroup? group) + { + selectedAssignmentGroup = group; + } + private LocalAssignmentGroup? selectedAssignmentGroup { get; set; } }