mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
can create and drag and drop pages
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
@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()
|
||||
{
|
||||
Console.WriteLine("new quiz");
|
||||
Console.WriteLine(selectedAssignmentGroup);
|
||||
if(Name.Trim() == string.Empty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var newQuiz = new LocalQuiz
|
||||
{
|
||||
Name=Name,
|
||||
Description = "",
|
||||
LocalAssignmentGroupName = selectedAssignmentGroup?.Name,
|
||||
};
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
var newModules = planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Quizzes=Module.Quizzes.Append(newQuiz)
|
||||
}
|
||||
);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=newModules
|
||||
};
|
||||
}
|
||||
modal?.Hide();
|
||||
}
|
||||
|
||||
private void setAssignmentGroup(LocalAssignmentGroup? group)
|
||||
{
|
||||
selectedAssignmentGroup = group;
|
||||
}
|
||||
private LocalAssignmentGroup? selectedAssignmentGroup { get; set; }
|
||||
}
|
||||
|
||||
<button
|
||||
class="btn btn-outline-secondary"
|
||||
@onclick="() => modal?.Show()"
|
||||
>
|
||||
+ Quiz
|
||||
</button>
|
||||
|
||||
<Modal @ref="modal">
|
||||
<Title>New Quiz</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>
|
||||
@if(planner != null && planner.LocalCourse != null)
|
||||
{
|
||||
<ButtonSelect
|
||||
Label="Assignment Group"
|
||||
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
||||
GetName="(g) => g?.Name"
|
||||
OnSelect="(g) => setAssignmentGroup(g)"
|
||||
/>
|
||||
}
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@onclick="submitHandler"
|
||||
>
|
||||
CreateQuiz
|
||||
</button>
|
||||
</Footer>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user