diff --git a/.editorconfig b/.editorconfig
index f9a4117..9f2cbb7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -10,3 +10,8 @@ dotnet_naming_symbols.private_methods.applicable_kinds = method
dotnet_naming_symbols.private_methods.applicable_accessibilities = private
dotnet_naming_style.camel_case_style.capitalization = camel_case
+
+
+[*.razor]
+indent_style = ignore
+indent_size = ignore
\ No newline at end of file
diff --git a/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor b/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor
index 96f5afa..dc8add2 100644
--- a/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor
+++ b/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor
@@ -85,10 +85,7 @@
}
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"
rows=12
@bind="currentDescription"
- @oninput="OnInputChanged"
+ @oninput="@((e) => SaveAssignment(Assignment with { Description = e.Value?.ToString() ?? "" }))"
/>
diff --git a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor
index 97b81d2..70e9c10 100644
--- a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor
+++ b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor
@@ -1,4 +1,5 @@
@using Management.Web.Shared.Components
+@using Management.Web.Shared.Components.AssignmentForm
@inject CoursePlanner planner
@inject CanvasService canvas
@@ -37,54 +38,29 @@
private void submitHandler()
{
- if(assignmentContext.Assignment != null)
+ if (assignmentContext.Assignment != null)
{
var totalRubricPoints = rubric
- .Where(r => !r.Label.Contains(RubricItem.extraCredit))
- .Select(s => s.Points)
- .Sum();
+ .Where(r => !r.Label.Contains(RubricItem.extraCredit))
+ .Select(s => s.Points)
+ .Sum();
var newAssignment = assignmentContext.Assignment with
- {
- Name = name,
- LockAtDueDate = lockAtDueDate,
- Rubric = rubric,
- PointsPossible = totalRubricPoints,
- SubmissionTypes = submissionTypes,
- };
-
- if (planner.LocalCourse != null)
- {
- 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
+ Name = name,
+ LockAtDueDate = lockAtDueDate,
+ Rubric = rubric,
+ PointsPossible = totalRubricPoints,
+ SubmissionTypes = submissionTypes,
};
- }
- AssignmentModal?.Hide();
- assignmentContext.Assignment = null;
+
+ assignmentContext.SaveAssignment(newAssignment);
}
+ AssignmentModal?.Hide();
+ assignmentContext.Assignment = null;
}
+
private void updateRubric(IEnumerable
newRubric)
{
rubric = newRubric;
@@ -103,26 +79,27 @@
var assignment = assignmentContext.Assignment;
var currentModule = planner
- .LocalCourse
- .Modules
- .First(m =>
- m.Assignments
- .Select(a => a.Id)
- .Contains(assignment.Id)
- ) ?? throw new Exception("handling assignment delete, could not find module");
+ .LocalCourse
+ .Modules
+ .First(m =>
+ m.Assignments
+ .Select(a => a.Id)
+ .Contains(assignment.Id)
+ ) ?? throw new Exception("handling assignment delete, could not find module");
+
var newModules = planner.LocalCourse.Modules.Select(m =>
- m.Name == currentModule.Name
- ? m with
- {
- Assignments = m.Assignments.Where(a => a.Id != assignment.Id).ToArray()
- }
- : m
+ m.Name == currentModule.Name
+ ? m with
+ {
+ Assignments = m.Assignments.Where(a => a.Id != assignment.Id).ToArray()
+ }
+ : m
).ToArray();
planner.LocalCourse = planner.LocalCourse with
- {
- Modules = newModules
- };
+ {
+ Modules = newModules
+ };
if (assignment.CanvasId != null && planner.LocalCourse.CanvasId != null)
{
ulong courseId = planner.LocalCourse.CanvasId ?? throw new Exception("cannot delete if no course id");
@@ -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);
+ }
+ }
}
@@ -138,36 +140,52 @@
- @if(assignmentContext.Assignment != null)
+ @if (assignmentContext.Assignment != null)
{
}
diff --git a/Management.Web/Shared/Components/AssignmentForm/RubricEditor.razor b/Management.Web/Shared/Components/AssignmentForm/RubricEditor.razor
index 5adecf1..6e6d425 100644
--- a/Management.Web/Shared/Components/AssignmentForm/RubricEditor.razor
+++ b/Management.Web/Shared/Components/AssignmentForm/RubricEditor.razor
@@ -1,64 +1,101 @@
@using Management.Web.Shared.Components
@inject CoursePlanner planner
+@inject AssignmentEditorContext assignmentContext
@code
{
- [Parameter, EditorRequired]
- public IEnumerable Rubric { get; set; } = default!;
+ private IEnumerable rubric { get; set; } = Array.Empty();
- [Parameter, EditorRequired]
- public Action> SetRubric { get; set; } = default!;
+ protected override void OnInitialized()
+ {
+ 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()
{
- SetRubric(
- Rubric.Append(new RubricItem
+ if (assignmentContext.Assignment != null)
+ {
+ rubric = rubric.Append(new RubricItem
{
- Id=Guid.NewGuid().ToString(),
- Label="",
- Points=0
- })
- );
- StateHasChanged();
+ Id = Guid.NewGuid().ToString(),
+ Label = "",
+ Points = 0
+ });
+ }
}
private void removeItem()
{
- SetRubric(
- Rubric.Take(Rubric.Count() - 1)
- );
- StateHasChanged();
+ if (assignmentContext.Assignment != null)
+ {
+ rubric = rubric.Take(rubric.Count() - 1);
+ save();
+ }
}
private void editItem(RubricItem newItem)
{
- var newRubric = Rubric.Select(i => i.Id == newItem.Id ? newItem : i);
- SetRubric(newRubric);
- StateHasChanged();
+ if (assignmentContext.Assignment != null)
+ {
+ rubric = rubric.Select(i => i.Id == newItem.Id ? newItem : i);
+ save();
+ }
}
private void MoveUp(RubricItem item)
{
- var rubricList = Rubric.ToList();
- var index = rubricList.IndexOf(item);
-
- if(index > 0)
+ if (assignmentContext.Assignment != null)
{
- var previous = rubricList[index - 1];
- rubricList[index - 1] = item;
- rubricList[index] = previous;
- SetRubric(rubricList);
+ var rubricList = rubric.ToList();
+ var index = rubricList.IndexOf(item);
+
+ if (index > 0)
+ {
+ var previous = rubricList[index - 1];
+ rubricList[index - 1] = item;
+ rubricList[index] = previous;
+ rubric = rubricList;
+ save();
+ }
}
}
private void MoveDown(RubricItem item)
{
- var rubricList = Rubric.ToList();
- var index = rubricList.IndexOf(item);
-
- if(index < rubricList.Count())
+ if (assignmentContext.Assignment != null)
{
- var next = rubricList[index + 1];
- rubricList[index + 1] = item;
- rubricList[index] = next;
- SetRubric(rubricList);
+ var rubricList = rubric.ToList();
+ var index = rubricList.IndexOf(item);
+
+ if (index < rubricList.Count())
+ {
+ var next = rubricList[index + 1];
+ rubricList[index + 1] = item;
+ rubricList[index] = next;
+ rubric = rubricList;
+ save();
+ }
}
}
}
@@ -66,7 +103,7 @@
Rubric
- @foreach (var rubricItem in Rubric)
+@foreach (var rubricItem in rubric)
{
+ rubric item
-
\ No newline at end of file
+
diff --git a/Management.Web/Shared/Semester/AssignmentInDay.razor b/Management.Web/Shared/Semester/AssignmentInDay.razor
index 68e4a96..523fe66 100644
--- a/Management.Web/Shared/Semester/AssignmentInDay.razor
+++ b/Management.Web/Shared/Semester/AssignmentInDay.razor
@@ -15,7 +15,6 @@
private void reload()
{
this.InvokeAsync(this.StateHasChanged);
- @* Console.WriteLine("on initialized " + showUpdateForm + " " + Assignment.Name); *@
}
public void Dispose()
{
diff --git a/Management/Features/Configuration/AssignmentEditorContext.cs b/Management/Features/Configuration/AssignmentEditorContext.cs
index ee46532..df637fc 100644
--- a/Management/Features/Configuration/AssignmentEditorContext.cs
+++ b/Management/Features/Configuration/AssignmentEditorContext.cs
@@ -26,7 +26,6 @@ public class AssignmentEditorContext
{
if (planner.LocalCourse != null)
{
- Console.WriteLine(newAssignment.Description);
var currentModule =
planner.LocalCourse.Modules.First(
m => m.Assignments.Select(a => a.Id).Contains(newAssignment.Id)