mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
adding template description fields to assignment form
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalAssignment Assignment
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public bool Show { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Action OnHide { get; set; } = () => { };
|
||||
public Modal AssignmentModal { get; set; } = default!;
|
||||
|
||||
private bool useTemplate { get; set; } = false;
|
||||
private string? templateId { get; set; }
|
||||
public Dictionary<string, string> templateVariables { get; set; } =
|
||||
new Dictionary<string, string>();
|
||||
private string description { get; set; } = String.Empty;
|
||||
private string name { get; set; } = String.Empty;
|
||||
private bool lockAtDueDate { get; set; }
|
||||
private IEnumerable<RubricItem> rubric { get; set; } = Enumerable.Empty<RubricItem>();
|
||||
private IEnumerable<SubmissionType> submissionTypes { get; set; } = Enumerable.Empty<SubmissionType>();
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if(Show)
|
||||
{
|
||||
AssignmentModal.Show();
|
||||
}
|
||||
name = Assignment.name;
|
||||
description = Assignment.description;
|
||||
lockAtDueDate = Assignment.lock_at_due_date;
|
||||
rubric = Assignment.rubric;
|
||||
submissionTypes = Assignment.submission_types;
|
||||
templateId = Assignment.template_id;
|
||||
useTemplate = Assignment.use_template;
|
||||
templateVariables = Assignment.template_variables;
|
||||
}
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
var totalRubricPoints = rubric
|
||||
.Where(r => !r.Label.Contains(RubricItem.extraCredit))
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
var newAssignment = Assignment with
|
||||
{
|
||||
name=name,
|
||||
description=description,
|
||||
lock_at_due_date=lockAtDueDate,
|
||||
rubric=rubric,
|
||||
points_possible=totalRubricPoints,
|
||||
submission_types=submissionTypes,
|
||||
use_template=useTemplate,
|
||||
template_id=templateId,
|
||||
template_variables=templateVariables,
|
||||
};
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Select(a =>
|
||||
a.id == newAssignment.id
|
||||
? newAssignment
|
||||
: a
|
||||
)
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
AssignmentModal.Hide();
|
||||
}
|
||||
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
||||
{
|
||||
rubric = newRubric;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||
<Title>
|
||||
@Assignment.name
|
||||
</Title>
|
||||
<Body>
|
||||
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
||||
<div class="m-1">
|
||||
<label
|
||||
class="form-label"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
class="form-control"
|
||||
@bind="name"
|
||||
/>
|
||||
</div>
|
||||
<div class="m-1">
|
||||
<AssignmentDescriptionEditor
|
||||
@bind-Description="description"
|
||||
@bind-UseTemplate="useTemplate"
|
||||
@bind-TemplateId="templateId"
|
||||
/>
|
||||
</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"
|
||||
>
|
||||
Lock At Due Date
|
||||
</label>
|
||||
</div>
|
||||
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
|
||||
<SubmissionTypeSelector
|
||||
Types="submissionTypes"
|
||||
SetTypes="(newTypes) => submissionTypes = newTypes"
|
||||
/>
|
||||
</form>
|
||||
</Body>
|
||||
<Footer>
|
||||
<button class="btn btn-primary" @onclick="submitHandler">
|
||||
Save
|
||||
</button>
|
||||
</Footer>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user