mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
am syncing assignment groups
This commit is contained in:
@@ -103,6 +103,9 @@
|
||||
>
|
||||
View In Canvas
|
||||
</a>
|
||||
<div class="my-auto ms-2 d-inline">
|
||||
@planner.LocalCourse.Name
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(planner.LoadingCanvasData)
|
||||
|
||||
@@ -35,6 +35,7 @@ builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddScoped<IWebRequestor, WebRequestor>();
|
||||
builder.Services.AddScoped<CanvasServiceUtils>();
|
||||
builder.Services.AddScoped<CanvasAssignmentService>();
|
||||
builder.Services.AddScoped<CanvasAssignmentGroupService>();
|
||||
builder.Services.AddScoped<CanvasQuizService>();
|
||||
builder.Services.AddScoped<CanvasService, CanvasService>();
|
||||
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
assignmentContext.StateHasChanged -= reload;
|
||||
}
|
||||
|
||||
|
||||
[Parameter]
|
||||
public Action OnHide { get; set; } = () => { };
|
||||
private void OnHide()
|
||||
{
|
||||
assignmentContext.Assignment = null;
|
||||
name = "";
|
||||
lockAtDueDate = false;
|
||||
}
|
||||
public Modal? AssignmentModal { get; set; } = null;
|
||||
private string name { get; set; } = String.Empty;
|
||||
private bool lockAtDueDate { get; set; }
|
||||
@@ -111,7 +114,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||
<Modal @ref="AssignmentModal" OnHide="OnHide" Size="xl">
|
||||
<Title>
|
||||
@assignmentContext.Assignment?.Name
|
||||
</Title>
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
[Parameter]
|
||||
public Action OnHide { get; set; } = () => { };
|
||||
|
||||
[Parameter]
|
||||
public string Size { get; set; } = "xl"; //sm, lg, xl, xxl
|
||||
|
||||
private string modalClass = "hide-modal";
|
||||
private bool showBackdrop = false;
|
||||
public void Show()
|
||||
@@ -33,7 +36,7 @@
|
||||
}
|
||||
|
||||
<div class="modal @modalClass" @onmousedown="Hide">
|
||||
<div class="modal-dialog modal-xl" role="document" @onmousedown:stopPropagation="true">
|
||||
<div class="@($"modal-dialog modal-{Size}")" role="document" @onmousedown:stopPropagation="true">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title text-center w-100">@Title</h4>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
private string text { get; set; } = string.Empty;
|
||||
private string questionType { get; set; } = string.Empty;
|
||||
private int points { get; set; }
|
||||
private int points { get; set; } = 1;
|
||||
private IEnumerable<LocalQuizQuestionAnswer> answers { get; set; } = Enumerable.Empty<LocalQuizQuestionAnswer>();
|
||||
|
||||
private void handleTypeUpdate(string type)
|
||||
|
||||
113
Management.Web/Shared/Course/AssignmentGroups.razor
Normal file
113
Management.Web/Shared/Course/AssignmentGroups.razor
Normal file
@@ -0,0 +1,113 @@
|
||||
@using Management.Web.Shared.Components
|
||||
@inject CanvasService canvas
|
||||
@inject CoursePlanner planner
|
||||
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
planner.StateHasChanged += reload;
|
||||
}
|
||||
private void reload()
|
||||
{
|
||||
this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
planner.StateHasChanged -= reload;
|
||||
}
|
||||
|
||||
private void AddAssignmentGroup()
|
||||
{
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
var newGroup = new LocalAssignmentGroup
|
||||
{
|
||||
Name = "",
|
||||
Weight = 0,
|
||||
Id = Guid.NewGuid().ToString()
|
||||
};
|
||||
|
||||
var updatedGroups = planner.LocalCourse.AssignmentGroups.Append(newGroup);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
AssignmentGroups = updatedGroups
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private Action<ChangeEventArgs> saveGroupName(string groupId)
|
||||
{
|
||||
return (e) =>
|
||||
{
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
var newName = e.Value?.ToString() ?? "";
|
||||
var newGroups = planner.LocalCourse.AssignmentGroups.Select(
|
||||
g => g.Id == groupId
|
||||
? g with { Name = newName }
|
||||
: g
|
||||
);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
AssignmentGroups = newGroups
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
private Action<ChangeEventArgs> saveGroupWeight(string groupId)
|
||||
{
|
||||
return (e) =>
|
||||
{
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
var newWeight = double.Parse(e.Value?.ToString() ?? "0");
|
||||
var newGroups = planner.LocalCourse.AssignmentGroups.Select(
|
||||
g => g.Id == groupId
|
||||
? g with { Weight = newWeight }
|
||||
: g
|
||||
);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
AssignmentGroups = newGroups
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@if(planner.LocalCourse != null)
|
||||
{
|
||||
<h4 class="text-center">Assignment Groups</h4>
|
||||
@foreach (var group in planner.LocalCourse.AssignmentGroups)
|
||||
{
|
||||
var groupName = group.Name;
|
||||
var nameInputCallback = saveGroupName(group.Id);
|
||||
var weight = group.Weight;
|
||||
var weightInputCallback = saveGroupWeight(group.Id);
|
||||
<div class="row">
|
||||
<div class="col-auto">
|
||||
<label class="form-label">Group Name</label>
|
||||
<input
|
||||
class="form-control"
|
||||
@bind="groupName" @oninput="nameInputCallback">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label">Weight</label>
|
||||
<input
|
||||
class="form-control"
|
||||
@bind="weight"
|
||||
@oninput="weightInputCallback"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="d-flex justify-content-end">
|
||||
<button
|
||||
class="btn btn-outline-primary"
|
||||
@onclick="AddAssignmentGroup"
|
||||
>
|
||||
+ Assignment Group
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
@@ -67,6 +67,7 @@
|
||||
<h1>Course Settings</h1>
|
||||
</Title>
|
||||
<Body>
|
||||
|
||||
<h5 class="text-center">Select Days Of Week</h5>
|
||||
<div class="row m-3">
|
||||
@foreach (DayOfWeek day in (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek)))
|
||||
@@ -144,6 +145,7 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<AssignmentGroups />
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user