mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
93 lines
2.2 KiB
Plaintext
93 lines
2.2 KiB
Plaintext
@using Management.Web.Shared.Components
|
|
@using Management.Web.Shared.Components.Forms
|
|
|
|
@inject CoursePlanner planner
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
[EditorRequired]
|
|
public LocalModule Module { get; set; } = default!;
|
|
|
|
[Required]
|
|
[StringLength(50, ErrorMessage = "Name too long (50 character limit).")]
|
|
private string Name { get; set; } = "";
|
|
|
|
private Modal? modal { get; set; } = null;
|
|
|
|
private void submitHandler()
|
|
{
|
|
System.Console.WriteLine("new assignment");
|
|
var newAssignment = new LocalAssignment
|
|
{
|
|
Name = Name,
|
|
Description = "",
|
|
LockAtDueDate = true,
|
|
Rubric = new RubricItem[] { },
|
|
LockAt = null,
|
|
DueAt = DateTime.Now,
|
|
PointsPossible = 10,
|
|
SubmissionTypes = new string[] { SubmissionType.ONLINE_TEXT_ENTRY },
|
|
LocalAssignmentGroupId = selectedAssignmentGroup?.Id,
|
|
};
|
|
|
|
if(planner.LocalCourse != null)
|
|
{
|
|
var newModules =planner.LocalCourse.Modules.Select(m =>
|
|
m.Name != Module.Name
|
|
? m
|
|
: Module with
|
|
{
|
|
Assignments=Module.Assignments.Append(newAssignment)
|
|
}
|
|
);
|
|
planner.LocalCourse = planner.LocalCourse with
|
|
{
|
|
Modules=newModules
|
|
};
|
|
}
|
|
Name = "";
|
|
modal?.Hide();
|
|
}
|
|
|
|
private void setAssignmentGroup(LocalAssignmentGroup? group)
|
|
{
|
|
selectedAssignmentGroup = group;
|
|
}
|
|
private LocalAssignmentGroup? selectedAssignmentGroup { get; set; }
|
|
}
|
|
|
|
<button
|
|
class="btn btn-outline-secondary"
|
|
@onclick="() => modal?.Show()"
|
|
>
|
|
+ Assignment
|
|
</button>
|
|
|
|
<Modal @ref="modal">
|
|
<Title>New Assignment</Title>
|
|
<Body>
|
|
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
|
<label for="Assignment Name">Name</label>
|
|
<input id="moduleName" class="form-control" @bind="Name" />
|
|
</form>
|
|
<br>
|
|
<label class="form-label">Assignment Group</label>
|
|
<ButtonSelect
|
|
Label="Assignment Group"
|
|
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
|
GetName="(g) => g?.Name"
|
|
OnSelect="(g) => setAssignmentGroup(g)"
|
|
/>
|
|
</Body>
|
|
<Footer>
|
|
<button
|
|
type="button"
|
|
class="btn btn-primary"
|
|
@onclick="submitHandler"
|
|
>
|
|
Create Assignment
|
|
</button>
|
|
</Footer>
|
|
</Modal> |