mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
can select assignment group for assignments and quizzes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
@using Management.Web.Shared.Components.AssignmentForm
|
@using Management.Web.Shared.Components.AssignmentForm
|
||||||
|
@using Management.Web.Shared.Components.Forms
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
@inject CanvasService canvas
|
@inject CanvasService canvas
|
||||||
@@ -112,6 +113,25 @@
|
|||||||
assignmentContext.SaveAssignment(newAssignment);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
<Modal @ref="AssignmentModal" OnHide="OnHide" Size="xl">
|
<Modal @ref="AssignmentModal" OnHide="OnHide" Size="xl">
|
||||||
@@ -132,6 +152,14 @@
|
|||||||
@oninput="handleNameChange"
|
@oninput="handleNameChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<ButtonSelect
|
||||||
|
Label="Assignment Group"
|
||||||
|
Options="planner.LocalCourse.AssignmentGroups"
|
||||||
|
GetId="(g) => g.Id"
|
||||||
|
GetName="(g) => g.Name"
|
||||||
|
OnSelect="(g) => setAssignmentGroup(g)"
|
||||||
|
SelectedOption="selectedAssignmentGroup"
|
||||||
|
/>
|
||||||
<div class="m-1">
|
<div class="m-1">
|
||||||
<AssignmentDescriptionEditor />
|
<AssignmentDescriptionEditor />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
56
Management.Web/Shared/Components/Forms/ButtonSelect.razor
Normal file
56
Management.Web/Shared/Components/Forms/ButtonSelect.razor
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
@typeparam T
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public string Label { get; set; } = string.Empty;
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public IEnumerable<T> Options { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Func<T, string> GetId { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Func<T, string> GetName { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Action<T?> 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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
@foreach(var option in Options)
|
||||||
|
{
|
||||||
|
<button
|
||||||
|
class="@getButtonClasS(option)"
|
||||||
|
@onclick="() => onSelect(option)"
|
||||||
|
>
|
||||||
|
@GetName(option)
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
48
Management.Web/Shared/Components/Forms/FormSelect.razor
Normal file
48
Management.Web/Shared/Components/Forms/FormSelect.razor
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
@typeparam T
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public string Label { get; set; } = string.Empty;
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public IEnumerable<T> Options { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Func<T, string> GetId { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Func<T, string> GetName { get; set; } = default!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public Action<T?> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="@htmlLabel">@Label</label>
|
||||||
|
<select
|
||||||
|
id="@htmlLabel"
|
||||||
|
name="@htmlLabel"
|
||||||
|
@bind="selectedItemId"
|
||||||
|
@oninput="onSelect"
|
||||||
|
>
|
||||||
|
@foreach(var option in Options)
|
||||||
|
{
|
||||||
|
<option
|
||||||
|
value="@(GetId(option))"
|
||||||
|
>
|
||||||
|
@GetName(option)
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
@using Management.Web.Shared.Components.Forms
|
||||||
|
|
||||||
@inject QuizEditorContext quizContext
|
@inject QuizEditorContext quizContext
|
||||||
|
@inject CoursePlanner planner
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
@@ -38,8 +40,9 @@
|
|||||||
|
|
||||||
private void handleLockAtDueDateChange()
|
private void handleLockAtDueDateChange()
|
||||||
{
|
{
|
||||||
if(quizContext.Quiz != null)
|
if(quizContext.Quiz == null)
|
||||||
{
|
return;
|
||||||
|
|
||||||
var newValue = !quizContext.Quiz.LockAtDueDate;
|
var newValue = !quizContext.Quiz.LockAtDueDate;
|
||||||
|
|
||||||
var newQuiz = newValue
|
var newQuiz = newValue
|
||||||
@@ -54,9 +57,28 @@
|
|||||||
};
|
};
|
||||||
quizContext.SaveQuiz(newQuiz);
|
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 )
|
||||||
|
{
|
||||||
<div>
|
<div>
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input
|
<input
|
||||||
@@ -71,4 +93,13 @@
|
|||||||
Lock at Due Date
|
Lock at Due Date
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<ButtonSelect
|
||||||
|
Label="Assignment Group"
|
||||||
|
Options="planner.LocalCourse.AssignmentGroups"
|
||||||
|
GetId="(g) => g.Id"
|
||||||
|
GetName="(g) => g.Name"
|
||||||
|
OnSelect="(g) => setAssignmentGroup(g)"
|
||||||
|
SelectedOption="selectedAssignmentGroup"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ public record LocalAssignment
|
|||||||
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
|
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
|
||||||
public DateTime? LockAt { get; init; }
|
public DateTime? LockAt { get; init; }
|
||||||
public DateTime DueAt { get; init; }
|
public DateTime DueAt { get; init; }
|
||||||
|
public string? LocalAssignmentGroupId { get; init; }
|
||||||
public int PointsPossible { get; init; }
|
public int PointsPossible { get; init; }
|
||||||
public IEnumerable<string> SubmissionTypes { get; init; } = Array.Empty<string>();
|
public IEnumerable<string> SubmissionTypes { get; init; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public record LocalQuiz
|
|||||||
public DateTime DueAt { get; init; }
|
public DateTime DueAt { get; init; }
|
||||||
public bool ShuffleAnswers { get; init; }
|
public bool ShuffleAnswers { get; init; }
|
||||||
public bool OneQuestionAtATime { get; init; }
|
public bool OneQuestionAtATime { get; init; }
|
||||||
|
public string? LocalAssignmentGroupId { get; init; }
|
||||||
public int AllowedAttempts { get; init; } = -1; // -1 is infinite
|
public int AllowedAttempts { get; init; } = -1; // -1 is infinite
|
||||||
// public bool ShowCorrectAnswers { get; init; }
|
// public bool ShowCorrectAnswers { get; init; }
|
||||||
// public int? TimeLimit { get; init; } = null;
|
// public int? TimeLimit { get; init; } = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user