mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
updated rubric editor to be live
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@using Management.Web.Shared.Components
|
||||
@using Management.Web.Shared.Components.AssignmentForm
|
||||
|
||||
@inject CoursePlanner planner
|
||||
@inject CanvasService canvas
|
||||
@@ -37,54 +38,29 @@
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
if(assignmentContext.Assignment != null)
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var totalRubricPoints = rubric
|
||||
.Where(r => !r.Label.Contains(RubricItem.extraCredit))
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
.Where(r => !r.Label.Contains(RubricItem.extraCredit))
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Name = name,
|
||||
LockAtDueDate = lockAtDueDate,
|
||||
Rubric = rubric,
|
||||
PointsPossible = totalRubricPoints,
|
||||
SubmissionTypes = submissionTypes,
|
||||
};
|
||||
|
||||
if (planner.LocalCourse != null)
|
||||
{
|
||||
var currentModule = planner
|
||||
.LocalCourse
|
||||
.Modules
|
||||
.First(m =>
|
||||
m.Assignments
|
||||
.Select(a => a.Id)
|
||||
.Contains(newAssignment.Id)
|
||||
) ?? throw new Exception("could not find current module in assignment form");
|
||||
var updatedModules = planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name == currentModule.Name
|
||||
? currentModule with
|
||||
{
|
||||
Assignments = currentModule.Assignments.Select(a =>
|
||||
a.Id == newAssignment.Id
|
||||
? newAssignment
|
||||
: a
|
||||
).ToArray()
|
||||
}
|
||||
: m
|
||||
).ToArray();
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules = updatedModules
|
||||
Name = name,
|
||||
LockAtDueDate = lockAtDueDate,
|
||||
Rubric = rubric,
|
||||
PointsPossible = totalRubricPoints,
|
||||
SubmissionTypes = submissionTypes,
|
||||
};
|
||||
}
|
||||
AssignmentModal?.Hide();
|
||||
assignmentContext.Assignment = null;
|
||||
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
AssignmentModal?.Hide();
|
||||
assignmentContext.Assignment = null;
|
||||
}
|
||||
|
||||
|
||||
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
||||
{
|
||||
rubric = newRubric;
|
||||
@@ -103,26 +79,27 @@
|
||||
var assignment = assignmentContext.Assignment;
|
||||
|
||||
var currentModule = planner
|
||||
.LocalCourse
|
||||
.Modules
|
||||
.First(m =>
|
||||
m.Assignments
|
||||
.Select(a => a.Id)
|
||||
.Contains(assignment.Id)
|
||||
) ?? throw new Exception("handling assignment delete, could not find module");
|
||||
.LocalCourse
|
||||
.Modules
|
||||
.First(m =>
|
||||
m.Assignments
|
||||
.Select(a => a.Id)
|
||||
.Contains(assignment.Id)
|
||||
) ?? throw new Exception("handling assignment delete, could not find module");
|
||||
|
||||
var newModules = planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name == currentModule.Name
|
||||
? m with
|
||||
{
|
||||
Assignments = m.Assignments.Where(a => a.Id != assignment.Id).ToArray()
|
||||
}
|
||||
: m
|
||||
m.Name == currentModule.Name
|
||||
? m with
|
||||
{
|
||||
Assignments = m.Assignments.Where(a => a.Id != assignment.Id).ToArray()
|
||||
}
|
||||
: m
|
||||
).ToArray();
|
||||
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules = newModules
|
||||
};
|
||||
{
|
||||
Modules = newModules
|
||||
};
|
||||
if (assignment.CanvasId != null && planner.LocalCourse.CanvasId != null)
|
||||
{
|
||||
ulong courseId = planner.LocalCourse.CanvasId ?? throw new Exception("cannot delete if no course id");
|
||||
@@ -130,6 +107,31 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNameChange(ChangeEventArgs e)
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var newAssignment = assignmentContext.Assignment with { Name = e.Value?.ToString() ?? "" };
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLockAtDueDateChange(ChangeEventArgs e)
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var lockAtDueDate = (bool)(e.Value ?? false);
|
||||
var lockAtDate = lockAtDueDate
|
||||
? assignmentContext.Assignment.DueAt
|
||||
: assignmentContext.Assignment.LockAt;
|
||||
var newAssignment = assignmentContext.Assignment with {
|
||||
LockAtDueDate = lockAtDueDate,
|
||||
LockAt = lockAtDate,
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||
@@ -138,36 +140,52 @@
|
||||
</Title>
|
||||
|
||||
<Body>
|
||||
@if(assignmentContext.Assignment != null)
|
||||
@if (assignmentContext.Assignment != null)
|
||||
{
|
||||
<form @onsubmit:preventDefault="true">
|
||||
<div class="m-1">
|
||||
<label class="form-label">
|
||||
Name
|
||||
</label>
|
||||
<input class="form-control" @bind="name" />
|
||||
<input
|
||||
class="form-control"
|
||||
@bind="name"
|
||||
@oninput="handleNameChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="m-1">
|
||||
<AssignmentDescriptionEditor Assignment="assignmentContext.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"
|
||||
@bind="lockAtDueDate"
|
||||
@oninput="handleLockAtDueDateChange"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="lockAtDueDate"
|
||||
>
|
||||
Lock At Due Date
|
||||
</label>
|
||||
</div>
|
||||
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
|
||||
<RubricEditor />
|
||||
<SubmissionTypeSelector Types="submissionTypes" SetTypes="SetTypes" />
|
||||
</form>
|
||||
}
|
||||
</Body>
|
||||
<Footer>
|
||||
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirmAsync="HandleDelete" />
|
||||
<button class="btn btn-primary" @onclick="@(() => {
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@onclick="@(() => {
|
||||
AssignmentModal?.Hide();
|
||||
assignmentContext.Assignment = null;
|
||||
})">
|
||||
})"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</Footer>
|
||||
|
||||
Reference in New Issue
Block a user