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:
@@ -10,3 +10,8 @@ dotnet_naming_symbols.private_methods.applicable_kinds = method
|
|||||||
dotnet_naming_symbols.private_methods.applicable_accessibilities = private
|
dotnet_naming_symbols.private_methods.applicable_accessibilities = private
|
||||||
|
|
||||||
dotnet_naming_style.camel_case_style.capitalization = camel_case
|
dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||||
|
|
||||||
|
|
||||||
|
[*.razor]
|
||||||
|
indent_style = ignore
|
||||||
|
indent_size = ignore
|
||||||
@@ -85,10 +85,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string? currentDescription { get; set; } = null;
|
private string? currentDescription { get; set; } = null;
|
||||||
private void OnInputChanged(ChangeEventArgs e)
|
|
||||||
{
|
|
||||||
SaveAssignment(Assignment with { Description = e.Value?.ToString() ?? "" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +184,7 @@ else
|
|||||||
class="form-control"
|
class="form-control"
|
||||||
rows=12
|
rows=12
|
||||||
@bind="currentDescription"
|
@bind="currentDescription"
|
||||||
@oninput="OnInputChanged"
|
@oninput="@((e) => SaveAssignment(Assignment with { Description = e.Value?.ToString() ?? "" }))"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
@using Management.Web.Shared.Components.AssignmentForm
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
@inject CanvasService canvas
|
@inject CanvasService canvas
|
||||||
@@ -53,37 +54,12 @@
|
|||||||
SubmissionTypes = submissionTypes,
|
SubmissionTypes = submissionTypes,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (planner.LocalCourse != null)
|
assignmentContext.SaveAssignment(newAssignment);
|
||||||
{
|
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
AssignmentModal?.Hide();
|
AssignmentModal?.Hide();
|
||||||
assignmentContext.Assignment = null;
|
assignmentContext.Assignment = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
||||||
{
|
{
|
||||||
@@ -110,6 +86,7 @@
|
|||||||
.Select(a => a.Id)
|
.Select(a => a.Id)
|
||||||
.Contains(assignment.Id)
|
.Contains(assignment.Id)
|
||||||
) ?? throw new Exception("handling assignment delete, could not find module");
|
) ?? throw new Exception("handling assignment delete, could not find module");
|
||||||
|
|
||||||
var newModules = planner.LocalCourse.Modules.Select(m =>
|
var newModules = planner.LocalCourse.Modules.Select(m =>
|
||||||
m.Name == currentModule.Name
|
m.Name == currentModule.Name
|
||||||
? m with
|
? m with
|
||||||
@@ -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())">
|
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||||
@@ -145,29 +147,45 @@
|
|||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
Name
|
Name
|
||||||
</label>
|
</label>
|
||||||
<input class="form-control" @bind="name" />
|
<input
|
||||||
|
class="form-control"
|
||||||
|
@bind="name"
|
||||||
|
@oninput="handleNameChange"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="m-1">
|
<div class="m-1">
|
||||||
<AssignmentDescriptionEditor Assignment="assignmentContext.Assignment" />
|
<AssignmentDescriptionEditor Assignment="assignmentContext.Assignment" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-check m-1">
|
<div class="form-check m-1">
|
||||||
<input class="form-check-input" id="lockAtDueDate" type="checkbox" />
|
<input
|
||||||
<label class="form-check-label" for="lockAtDueDate" @bind="lockAtDueDate">
|
class="form-check-input"
|
||||||
|
id="lockAtDueDate"
|
||||||
|
type="checkbox"
|
||||||
|
@bind="lockAtDueDate"
|
||||||
|
@oninput="handleLockAtDueDateChange"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
class="form-check-label"
|
||||||
|
for="lockAtDueDate"
|
||||||
|
>
|
||||||
Lock At Due Date
|
Lock At Due Date
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
|
<RubricEditor />
|
||||||
<SubmissionTypeSelector Types="submissionTypes" SetTypes="SetTypes" />
|
<SubmissionTypeSelector Types="submissionTypes" SetTypes="SetTypes" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
</Body>
|
</Body>
|
||||||
<Footer>
|
<Footer>
|
||||||
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirmAsync="HandleDelete" />
|
<ConfirmationModal Label="Delete" Class="btn btn-danger" OnConfirmAsync="HandleDelete" />
|
||||||
<button class="btn btn-primary" @onclick="@(() => {
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
@onclick="@(() => {
|
||||||
AssignmentModal?.Hide();
|
AssignmentModal?.Hide();
|
||||||
assignmentContext.Assignment = null;
|
assignmentContext.Assignment = null;
|
||||||
})">
|
})"
|
||||||
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
</Footer>
|
</Footer>
|
||||||
|
|||||||
@@ -1,43 +1,74 @@
|
|||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
|
@inject AssignmentEditorContext assignmentContext
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
[Parameter, EditorRequired]
|
private IEnumerable<RubricItem> rubric { get; set; } = Array.Empty<RubricItem>();
|
||||||
public IEnumerable<RubricItem> Rubric { get; set; } = default!;
|
|
||||||
|
|
||||||
[Parameter, EditorRequired]
|
protected override void OnInitialized()
|
||||||
public Action<IEnumerable<RubricItem>> SetRubric { get; set; } = default!;
|
{
|
||||||
|
assignmentContext.StateHasChanged += reload;
|
||||||
|
}
|
||||||
|
private void reload()
|
||||||
|
{
|
||||||
|
if (assignmentContext.Assignment != null)
|
||||||
|
{
|
||||||
|
rubric = assignmentContext.Assignment.Rubric;
|
||||||
|
}
|
||||||
|
this.InvokeAsync(this.StateHasChanged);
|
||||||
|
}
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
assignmentContext.StateHasChanged -= reload;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save()
|
||||||
|
{
|
||||||
|
if (assignmentContext.Assignment != null)
|
||||||
|
{
|
||||||
|
var newAssignment = assignmentContext.Assignment with
|
||||||
|
{
|
||||||
|
Rubric = rubric
|
||||||
|
};
|
||||||
|
assignmentContext.SaveAssignment(newAssignment);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
private void addItem()
|
private void addItem()
|
||||||
{
|
{
|
||||||
SetRubric(
|
if (assignmentContext.Assignment != null)
|
||||||
Rubric.Append(new RubricItem
|
{
|
||||||
|
rubric = rubric.Append(new RubricItem
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid().ToString(),
|
Id = Guid.NewGuid().ToString(),
|
||||||
Label = "",
|
Label = "",
|
||||||
Points = 0
|
Points = 0
|
||||||
})
|
});
|
||||||
);
|
}
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
private void removeItem()
|
private void removeItem()
|
||||||
{
|
{
|
||||||
SetRubric(
|
if (assignmentContext.Assignment != null)
|
||||||
Rubric.Take(Rubric.Count() - 1)
|
{
|
||||||
);
|
rubric = rubric.Take(rubric.Count() - 1);
|
||||||
StateHasChanged();
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void editItem(RubricItem newItem)
|
private void editItem(RubricItem newItem)
|
||||||
{
|
{
|
||||||
var newRubric = Rubric.Select(i => i.Id == newItem.Id ? newItem : i);
|
if (assignmentContext.Assignment != null)
|
||||||
SetRubric(newRubric);
|
{
|
||||||
StateHasChanged();
|
rubric = rubric.Select(i => i.Id == newItem.Id ? newItem : i);
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void MoveUp(RubricItem item)
|
private void MoveUp(RubricItem item)
|
||||||
{
|
{
|
||||||
var rubricList = Rubric.ToList();
|
if (assignmentContext.Assignment != null)
|
||||||
|
{
|
||||||
|
var rubricList = rubric.ToList();
|
||||||
var index = rubricList.IndexOf(item);
|
var index = rubricList.IndexOf(item);
|
||||||
|
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
@@ -45,12 +76,16 @@
|
|||||||
var previous = rubricList[index - 1];
|
var previous = rubricList[index - 1];
|
||||||
rubricList[index - 1] = item;
|
rubricList[index - 1] = item;
|
||||||
rubricList[index] = previous;
|
rubricList[index] = previous;
|
||||||
SetRubric(rubricList);
|
rubric = rubricList;
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void MoveDown(RubricItem item)
|
private void MoveDown(RubricItem item)
|
||||||
{
|
{
|
||||||
var rubricList = Rubric.ToList();
|
if (assignmentContext.Assignment != null)
|
||||||
|
{
|
||||||
|
var rubricList = rubric.ToList();
|
||||||
var index = rubricList.IndexOf(item);
|
var index = rubricList.IndexOf(item);
|
||||||
|
|
||||||
if (index < rubricList.Count())
|
if (index < rubricList.Count())
|
||||||
@@ -58,7 +93,9 @@
|
|||||||
var next = rubricList[index + 1];
|
var next = rubricList[index + 1];
|
||||||
rubricList[index + 1] = item;
|
rubricList[index + 1] = item;
|
||||||
rubricList[index] = next;
|
rubricList[index] = next;
|
||||||
SetRubric(rubricList);
|
rubric = rubricList;
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +103,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<h5>Rubric</h5>
|
<h5>Rubric</h5>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
@foreach (var rubricItem in Rubric)
|
@foreach (var rubricItem in rubric)
|
||||||
{
|
{
|
||||||
<RubricEditorItem
|
<RubricEditorItem
|
||||||
RubricItem="rubricItem"
|
RubricItem="rubricItem"
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
private void reload()
|
private void reload()
|
||||||
{
|
{
|
||||||
this.InvokeAsync(this.StateHasChanged);
|
this.InvokeAsync(this.StateHasChanged);
|
||||||
@* Console.WriteLine("on initialized " + showUpdateForm + " " + Assignment.Name); *@
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ public class AssignmentEditorContext
|
|||||||
{
|
{
|
||||||
if (planner.LocalCourse != null)
|
if (planner.LocalCourse != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine(newAssignment.Description);
|
|
||||||
var currentModule =
|
var currentModule =
|
||||||
planner.LocalCourse.Modules.First(
|
planner.LocalCourse.Modules.First(
|
||||||
m => m.Assignments.Select(a => a.Id).Contains(newAssignment.Id)
|
m => m.Assignments.Select(a => a.Id).Contains(newAssignment.Id)
|
||||||
|
|||||||
Reference in New Issue
Block a user