updated how assignment form persists data

This commit is contained in:
2023-08-08 16:40:16 -06:00
parent 1494fd1906
commit b7e65e3914
3 changed files with 95 additions and 109 deletions

View File

@@ -30,8 +30,11 @@
public Dictionary<string, string> VariableValues { get; set; } = new Dictionary<string, string>();
protected override void OnParametersSet()
{
if (Description == "")
{
Description = Assignment.Description;
}
TemplateId = Assignment.TemplateId;
UseTemplate = Assignment.TemplateId != null && Assignment.TemplateId != "";
}
@@ -87,6 +90,7 @@
role="switch"
id="useTemplateForDescription"
@bind="UseTemplate"
/>
<label class="form-check-label" for="useTemplateForDescription">
use template for description
</label>
@@ -173,6 +177,7 @@ else
id="description"
class="form-control"
rows=12
value="@Description"
@oninput="@((e) =>
{
var newDescription = e.Value?.ToString();

View File

@@ -39,7 +39,7 @@
protected override void OnParametersSet()
{
if(Show)
if (Show)
{
AssignmentModal?.Show();
}
@@ -58,14 +58,14 @@
var newAssignment = Assignment with
{
Name=name,
LockAtDueDate=lockAtDueDate,
Rubric=rubric,
PointsPossible=totalRubricPoints,
SubmissionTypes=submissionTypes,
Name = name,
LockAtDueDate = lockAtDueDate,
Rubric = rubric,
PointsPossible = totalRubricPoints,
SubmissionTypes = submissionTypes,
};
if(planner.LocalCourse != null)
if (planner.LocalCourse != null)
{
var currentModule = planner
.LocalCourse
@@ -79,7 +79,7 @@
m.Name == currentModule.Name
? currentModule with
{
Assignments=currentModule.Assignments.Select(a =>
Assignments = currentModule.Assignments.Select(a =>
a.Id == newAssignment.Id
? newAssignment
: a
@@ -89,7 +89,7 @@
).ToArray();
planner.LocalCourse = planner.LocalCourse with
{
Modules=updatedModules
Modules = updatedModules
};
}
AssignmentModal?.Hide();
@@ -108,7 +108,7 @@
private async Task HandleDelete()
{
if(planner.LocalCourse != null)
if (planner.LocalCourse != null)
{
var assignment = Assignment;
var currentModule = planner
@@ -132,7 +132,7 @@
{
Modules = newModules
};
if(assignment.CanvasId != null && planner.LocalCourse.CanvasId != null)
if (assignment.CanvasId != null && planner.LocalCourse.CanvasId != null)
{
ulong courseId = planner.LocalCourse.CanvasId ?? throw new Exception("cannot delete if no course id");
await canvas.Assignments.Delete(courseId, assignment);
@@ -145,52 +145,31 @@
<Title>
@Assignment.Name
</Title>
<Body>
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
<div class="m-1">
<label
class="form-label"
>
<label class="form-label">
Name
</label>
<input
class="form-control"
@bind="name"
/>
<input class="form-control" @bind="name" />
</div>
<div class="m-1">
<AssignmentDescriptionEditor
Assignment="Assignment"
/>
<AssignmentDescriptionEditor Assignment="Assignment" />
</div>
<div class="form-check m-1">
<input
class="form-check-input"
id="lockAtDueDate"
type="checkbox"
/>
<label
class="form-check-label"
for="lockAtDueDate"
@bind="lockAtDueDate"
>
<input class="form-check-input" id="lockAtDueDate" type="checkbox" />
<label class="form-check-label" for="lockAtDueDate" @bind="lockAtDueDate">
Lock At Due Date
</label>
</div>
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
<SubmissionTypeSelector
Types="submissionTypes"
SetTypes="SetTypes"
/>
<SubmissionTypeSelector Types="submissionTypes" SetTypes="SetTypes" />
</form>
</Body>
<Footer>
<ConfirmationModal
Label="Delete"
Class="btn btn-danger"
OnConfirmAsync="HandleDelete"
/>
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirmAsync="HandleDelete" />
<button class="btn btn-primary" @onclick="@(() => AssignmentModal?.Hide())">
Save
</button>

View File

@@ -31,8 +31,8 @@
}
}
<div class="modal @modalClass">
<div class="modal-dialog modal-xl" role="document">
<div class="modal @modalClass" @onclick="Hide">
<div class="modal-dialog modal-xl" role="document" @onclick:stopPropagation="true">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-center w-100">@Title</h4>
@@ -46,5 +46,7 @@
@if (showBackdrop)
{
<div class="modal-backdrop fade show"></div>
<div
class="modal-backdrop fade show"
></div>
}