diff --git a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor index ddcf275..481e8ff 100644 --- a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor +++ b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor @@ -1,5 +1,6 @@ @using Management.Web.Shared.Components @using Management.Web.Shared.Components.AssignmentForm +@using Management.Web.Shared.Components.Forms @inject CoursePlanner planner @inject CanvasService canvas @@ -112,6 +113,25 @@ assignmentContext.SaveAssignment(newAssignment); } } + + private void setAssignmentGroup(LocalAssignmentGroup group) + { + if(assignmentContext.Assignment == null) + return; + + var newAssignment = assignmentContext.Assignment with + { + LocalAssignmentGroupId = group.Id + }; + + assignmentContext.SaveAssignment(newAssignment); + } + + private LocalAssignmentGroup? selectedAssignmentGroup => + planner + .LocalCourse? + .AssignmentGroups + .FirstOrDefault(g => g.Id == assignmentContext.Assignment?.LocalAssignmentGroupId); } @@ -132,6 +152,14 @@ @oninput="handleNameChange" /> +
diff --git a/Management.Web/Shared/Components/Forms/ButtonSelect.razor b/Management.Web/Shared/Components/Forms/ButtonSelect.razor new file mode 100644 index 0000000..1676960 --- /dev/null +++ b/Management.Web/Shared/Components/Forms/ButtonSelect.razor @@ -0,0 +1,56 @@ + +@typeparam T + +@code { + [Parameter, EditorRequired] + public string Label { get; set; } = string.Empty; + [Parameter, EditorRequired] + public IEnumerable Options { get; set; } = default!; + + [Parameter, EditorRequired] + public Func GetId { get; set; } = default!; + + [Parameter, EditorRequired] + public Func GetName { get; set; } = default!; + + [Parameter, EditorRequired] + public Action OnSelect { get; set; } = default!; + + [Parameter, EditorRequired] + public T? SelectedOption { get; set; } + + protected override void OnParametersSet() + { + selectedItemId = SelectedOption != null ? GetId(SelectedOption) : ""; + + } + + private string htmlLabel => Label.Replace("-", ""); + + private string selectedItemId { get; set; } + + private void onSelect(T option) + { + SelectedOption = option; + selectedItemId = GetId(option); + OnSelect(SelectedOption); + } + + private string getButtonClasS(T option) + { + var partClass = selectedItemId == GetId(option) ? "primary" : "outline-primary"; + return $"mx-1 btn btn-{partClass}"; + } +} + +
+ @foreach(var option in Options) + { + + } +
\ No newline at end of file diff --git a/Management.Web/Shared/Components/Forms/FormSelect.razor b/Management.Web/Shared/Components/Forms/FormSelect.razor new file mode 100644 index 0000000..782234a --- /dev/null +++ b/Management.Web/Shared/Components/Forms/FormSelect.razor @@ -0,0 +1,48 @@ + +@typeparam T + +@code { + [Parameter, EditorRequired] + public string Label { get; set; } = string.Empty; + [Parameter, EditorRequired] + public IEnumerable Options { get; set; } = default!; + + [Parameter, EditorRequired] + public Func GetId { get; set; } = default!; + + [Parameter, EditorRequired] + public Func GetName { get; set; } = default!; + + [Parameter, EditorRequired] + public Action OnSelect { get; set; } = default!; + + private string htmlLabel => Label.Replace("-", ""); + + private string selectedItemId { get; set; } + + private void onSelect(ChangeEventArgs e) + { + var newId = e.Value?.ToString(); + var selectedOption = Options.FirstOrDefault(o => GetId(o) == newId); + OnSelect(selectedOption); + } +} + +
+ + +
\ No newline at end of file diff --git a/Management.Web/Shared/Components/Quiz/QuizSettings.razor b/Management.Web/Shared/Components/Quiz/QuizSettings.razor index d7836c2..f0442fc 100644 --- a/Management.Web/Shared/Components/Quiz/QuizSettings.razor +++ b/Management.Web/Shared/Components/Quiz/QuizSettings.razor @@ -1,6 +1,8 @@ @using Management.Web.Shared.Components +@using Management.Web.Shared.Components.Forms @inject QuizEditorContext quizContext +@inject CoursePlanner planner @code { protected override void OnInitialized() @@ -38,37 +40,66 @@ private void handleLockAtDueDateChange() { - if(quizContext.Quiz != null) - { - var newValue = !quizContext.Quiz.LockAtDueDate; + if(quizContext.Quiz == null) + return; - var newQuiz = newValue - ? quizContext.Quiz with - { - LockAtDueDate = newValue, - LockAt = quizContext.Quiz.DueAt - } - : quizContext.Quiz with - { - LockAtDueDate = newValue - }; - quizContext.SaveQuiz(newQuiz); - } + var newValue = !quizContext.Quiz.LockAtDueDate; + + var newQuiz = newValue + ? quizContext.Quiz with + { + LockAtDueDate = newValue, + LockAt = quizContext.Quiz.DueAt + } + : quizContext.Quiz with + { + LockAtDueDate = newValue + }; + quizContext.SaveQuiz(newQuiz); } -} -
-
- - + private void setAssignmentGroup(LocalAssignmentGroup group) + { + if(quizContext.Quiz == null) + return; + + var newQuiz = quizContext.Quiz with + { + LocalAssignmentGroupId = group.Id + }; + + quizContext.SaveQuiz(newQuiz); + } + + private LocalAssignmentGroup? selectedAssignmentGroup => + planner + .LocalCourse? + .AssignmentGroups + .FirstOrDefault(g => g.Id == quizContext.Quiz?.LocalAssignmentGroupId); +} +@if(planner.LocalCourse != null ) +{ +
+
+ + +
+
-
\ No newline at end of file +} \ No newline at end of file diff --git a/Management/Models/Local/LocalAssignment.cs b/Management/Models/Local/LocalAssignment.cs index 7960d11..4a4d357 100644 --- a/Management/Models/Local/LocalAssignment.cs +++ b/Management/Models/Local/LocalAssignment.cs @@ -49,6 +49,7 @@ public record LocalAssignment public IEnumerable Rubric { get; init; } = Array.Empty(); public DateTime? LockAt { get; init; } public DateTime DueAt { get; init; } + public string? LocalAssignmentGroupId { get; init; } public int PointsPossible { get; init; } public IEnumerable SubmissionTypes { get; init; } = Array.Empty(); diff --git a/Management/Models/Local/LocalQuiz.cs b/Management/Models/Local/LocalQuiz.cs index de77514..c74d9a2 100644 --- a/Management/Models/Local/LocalQuiz.cs +++ b/Management/Models/Local/LocalQuiz.cs @@ -11,6 +11,7 @@ public record LocalQuiz public DateTime DueAt { get; init; } public bool ShuffleAnswers { get; init; } public bool OneQuestionAtATime { get; init; } + public string? LocalAssignmentGroupId { get; init; } public int AllowedAttempts { get; init; } = -1; // -1 is infinite // public bool ShowCorrectAnswers { get; init; } // public int? TimeLimit { get; init; } = null;