From b39fd9f223672a93a20776275576ebc500d634c1 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Wed, 18 Oct 2023 11:26:34 -0600 Subject: [PATCH] major layout changes for quizzes --- Management.Web/Pages/QuizFormPage.razor | 132 +++++++++++++++--- .../Shared/Components/ConfirmationModal.razor | 5 + .../Quiz/Markdown/MarkdownQuizForm.razor | 83 +++++++---- .../Quiz/Markdown/QuizPreview.razor | 59 ++++---- Management.Web/Shared/MainLayout.razor | 2 +- Management.Web/wwwroot/css/site.css | 34 ++++- .../Services/Canvas/CanvasServiceUtils.cs | 6 +- 7 files changed, 241 insertions(+), 80 deletions(-) diff --git a/Management.Web/Pages/QuizFormPage.razor b/Management.Web/Pages/QuizFormPage.razor index 9c4fe04..c14ab24 100644 --- a/Management.Web/Pages/QuizFormPage.razor +++ b/Management.Web/Pages/QuizFormPage.razor @@ -1,6 +1,7 @@ @page "/course/{CourseName}/quiz/{QuizName}" @using CanvasModel.EnrollmentTerms +@using CanvasModel.Quizzes @using Management.Web.Shared.Components.AssignmentForm @using Management.Web.Shared.Course @using Management.Web.Shared.Module.Assignment.Templates @@ -26,6 +27,7 @@ public string? QuizName { get; set; } = default!; private bool loading { get; set; }= true; + private bool addingQuizToCanvas = false; protected override async Task OnInitializedAsync() { @@ -51,6 +53,13 @@ quizContext.Quiz = quiz; logger.LogInformation($"set quiz to '{quizContext.Quiz?.Name}'"); } + StateHasChanged(); + + if(planner.CanvasQuizzes == null) + { + await planner.LoadCanvasData(); + } + base.OnInitialized(); StateHasChanged(); } @@ -64,37 +73,116 @@ private async Task addToCanvas() { + addingQuizToCanvas = true; await quizContext.AddQuizToCanvas(); + await planner.LoadCanvasData(); + addingQuizToCanvas = false; } private void done() { quizContext.Quiz = null; Navigation.NavigateTo("/course/" + planner.LocalCourse?.Settings.Name); } + + 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}"; } -@if(quizContext.Quiz == null) -{ - -} +
-@if(quizContext.Quiz != null) -{ - -} +
+
+
+

+ @quizContext.Quiz?.Name +

+
- -@if(quizContext.Quiz != null) -{ -
-
- - - + @if(quizContext.Quiz == null) + { +
+ +
+ } +
+

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

+ @if(quizInCanvas != null) + { + @if(quizInCanvas?.Published == true) + { +
+ Published! +
+ } + else + { +
+ Not Published +
+ } + } +
-
-} \ No newline at end of file +
+ +
+
+ @if(quizContext.Quiz != null) + { + + } +
+
+ +
+
+ @if(quizContext.Quiz != null) + { +
+
+ + + @if(quizInCanvas != null) + { + + View in Canvas + + } + +
+
+ } + + @if(addingQuizToCanvas) + { + + } +
+
\ No newline at end of file diff --git a/Management.Web/Shared/Components/ConfirmationModal.razor b/Management.Web/Shared/Components/ConfirmationModal.razor index dc2c07f..4528bb3 100644 --- a/Management.Web/Shared/Components/ConfirmationModal.razor +++ b/Management.Web/Shared/Components/ConfirmationModal.razor @@ -15,6 +15,8 @@ [Parameter] [EditorRequired] public string Class { get; set; } = ""; + [Parameter] + public bool Disabled { get; set; } = false; private Modal? modal { get; set; } = null; @@ -49,6 +51,7 @@ @@ -60,12 +63,14 @@ diff --git a/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor b/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor index 52c2d77..a9c1145 100644 --- a/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor +++ b/Management.Web/Shared/Components/Quiz/Markdown/MarkdownQuizForm.razor @@ -2,13 +2,13 @@ @inject QuizEditorContext quizContext - @code { private Modal? modal { get; set; } private LocalQuiz testQuiz; private string? error { get; set; } = null; + private bool showHelp = false; private string _quizMarkdownInput { get; set; } = ""; private string quizMarkdownInput { @@ -53,33 +53,68 @@ quizContext.StateHasChanged -= reload; } + private readonly static string exampleMarkdownQuestion = @"HELP +--- +Points: 2 +this is a question? +*a) correct +b) not correct +--- +points: 1 +question goes here +[*] correct +[ ] not correct +[] not correct +--- +the points default to 1? +*a) true +b) false +--- +Markdown is supported + +- like +- this +- list + +[*] true +[ ] false +"; + } +
-
-
-

- @quizContext.Quiz?.Name -

-
-
-

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

-
-
- -
-
-