mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
working on rubric
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
_selectedTermId = value;
|
||||
if(selectedTerm != null && planner.LocalCourse != null)
|
||||
{
|
||||
System.Console.WriteLine(JsonSerializer.Serialize(selectedTerm));
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
StartDate=selectedTerm.StartAt ?? new DateTime(),
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalAssignment assignment { get; set; } = new();
|
||||
public LocalAssignment Assignment { get; set; } = new();
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule module { get; set; } = new();
|
||||
public LocalModule Module { get; set; } = new();
|
||||
private bool showUpdateForm = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -33,12 +33,12 @@
|
||||
var newCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules = planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != module.Name
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: m with
|
||||
{
|
||||
Assignments = module.Assignments.Select(a =>
|
||||
a.id != assignment.id
|
||||
Assignments = Module.Assignments.Select(a =>
|
||||
a.id != Assignment.id
|
||||
? a
|
||||
: a with
|
||||
{
|
||||
@@ -70,13 +70,13 @@
|
||||
>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title">@assignment.name</div>
|
||||
<div class="card-title">@Assignment.name</div>
|
||||
<div class="card-text">
|
||||
@assignment.description
|
||||
<div>Due At: @assignment.due_at</div>
|
||||
<div>Lock At: @assignment.lock_at</div>
|
||||
<div>Points: @assignment.points_possible</div>
|
||||
@if(assignment.canvasId != null)
|
||||
@Assignment.description
|
||||
<div>Due At: @Assignment.due_at</div>
|
||||
<div>Lock At: @Assignment.lock_at</div>
|
||||
<div>Points: @Assignment.points_possible</div>
|
||||
@if(Assignment.canvasId != null)
|
||||
{
|
||||
<div>Synced with canvas</div>
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
{
|
||||
<div>Not synced with canvas</div>
|
||||
}
|
||||
<code>@JsonSerializer.Serialize(@assignment.rubric)</code>
|
||||
<code>@JsonSerializer.Serialize(Assignment.rubric)</code>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -92,7 +92,8 @@
|
||||
</div>
|
||||
|
||||
<AssignmentForm
|
||||
assignment="assignment"
|
||||
Assignment="Assignment"
|
||||
Show="showUpdateForm"
|
||||
OnHide="@(() => showUpdateForm = false)"
|
||||
Module="Module"
|
||||
/>
|
||||
@@ -1,9 +1,15 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalAssignment assignment
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalAssignment Assignment
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -15,9 +21,11 @@
|
||||
|
||||
[Parameter]
|
||||
public Action OnHide { get; set; } = () => { };
|
||||
public Modal AssignmentModal { get; set; }
|
||||
public Modal AssignmentModal { get; set; } = default!;
|
||||
|
||||
private string description { get; set; }
|
||||
private string description { get; set; } = String.Empty;
|
||||
private bool lockAtDueDate { get; set; }
|
||||
private IEnumerable<RubricItem> rubric { get; set; } = Enumerable.Empty<RubricItem>();
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
@@ -25,30 +33,81 @@
|
||||
{
|
||||
AssignmentModal.Show();
|
||||
}
|
||||
description = assignment.description;
|
||||
description = Assignment.description;
|
||||
lockAtDueDate = Assignment.lock_at_due_date;
|
||||
rubric = Assignment.rubric;
|
||||
}
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
|
||||
var newAssignment = Assignment with
|
||||
{
|
||||
description=description,
|
||||
lock_at_due_date=lockAtDueDate,
|
||||
rubric=rubric,
|
||||
};
|
||||
System.Console.WriteLine(JsonSerializer.Serialize(newAssignment));
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Select(a =>
|
||||
a.id == newAssignment.id
|
||||
? newAssignment
|
||||
: a
|
||||
)
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
AssignmentModal.Hide();
|
||||
}
|
||||
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
||||
{
|
||||
rubric = newRubric;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||
<Title>@assignment.name</Title>
|
||||
<Title>@Assignment.name</Title>
|
||||
<Body>
|
||||
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
||||
<label
|
||||
for="description"
|
||||
class="form-label"
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
class="form-control"
|
||||
@bind="description"
|
||||
/>
|
||||
<div class="m-1">
|
||||
<label
|
||||
for="description"
|
||||
class="form-label"
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
class="form-control"
|
||||
@bind="description"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-check m-1">
|
||||
<input
|
||||
class="form-check-input"
|
||||
id="lockAtDueDate"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="lockAtDueDate"
|
||||
@bind="lockAtDueDate"
|
||||
>
|
||||
Lock At Due Date
|
||||
</label>
|
||||
</div>
|
||||
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
|
||||
</form>
|
||||
</Body>
|
||||
<Footer>
|
||||
|
||||
49
Management.Web/Shared/Module/Assignment/RubricEditor.razor
Normal file
49
Management.Web/Shared/Module/Assignment/RubricEditor.razor
Normal file
@@ -0,0 +1,49 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter, EditorRequired]
|
||||
public IEnumerable<RubricItem> Rubric { get; set; } = default!;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<IEnumerable<RubricItem>> SetRubric { get; set; } = default!;
|
||||
|
||||
private void addItem()
|
||||
{
|
||||
SetRubric(
|
||||
Rubric.Append(new RubricItem
|
||||
{
|
||||
Id=Guid.NewGuid().ToString(),
|
||||
Label="",
|
||||
Points=0
|
||||
})
|
||||
);
|
||||
StateHasChanged();
|
||||
}
|
||||
private void editItem(RubricItem newItem)
|
||||
{
|
||||
var newRubric = Rubric.Select(i => i.Id == newItem.Id ? newItem : i);
|
||||
SetRubric(newRubric);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
<br>
|
||||
<h5>Rubric</h5>
|
||||
<ul class="list-group">
|
||||
@foreach (var rubricItem in Rubric)
|
||||
{
|
||||
<RubricEditorItem RubricItem="rubricItem" OnUpdate="editItem" />
|
||||
}
|
||||
</ul>
|
||||
|
||||
<button
|
||||
@onclick:preventDefault="true"
|
||||
@onclick="addItem"
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
>
|
||||
+ rubric item
|
||||
</button>
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter, EditorRequired]
|
||||
public RubricItem RubricItem { get; set; } = default!;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<RubricItem> OnUpdate { get; set; } = default!;
|
||||
private void editItem(string label, int points)
|
||||
{
|
||||
var newRubricItem = RubricItem with
|
||||
{
|
||||
Label = label,
|
||||
Points = points
|
||||
};
|
||||
OnUpdate(newRubricItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
<li
|
||||
class="list-group-item"
|
||||
>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label for="rubricLabel">Label</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="rubricLabel"
|
||||
name="rubricLabel"
|
||||
@oninput="@(e => editItem(e.Value?.ToString() ?? "", RubricItem.Points))"
|
||||
value="@RubricItem.Label"
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label for="rubricPoints">Points</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="rubricPoints"
|
||||
name="rubricPoints"
|
||||
@oninput="@(e => editItem(
|
||||
RubricItem.Label,
|
||||
int.Parse(e.Value?.ToString() != "" ? e.Value?.ToString() ?? "0" : "0"))
|
||||
)"
|
||||
value="@RubricItem.Points"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@@ -63,7 +63,7 @@
|
||||
<div class="row">
|
||||
@foreach (var a in Module.Assignments)
|
||||
{
|
||||
<AssignmentDetails assignment="a" module="Module" />
|
||||
<AssignmentDetails Assignment="a" Module="Module" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -49,12 +49,14 @@
|
||||
{
|
||||
DayOfWeek? weekDay = date?.DayOfWeek;
|
||||
DayOfWeek notNullDay = weekDay ?? default;
|
||||
|
||||
var isClassDay = planner.LocalCourse?.DaysOfWeek.Contains(notNullDay) ?? false;
|
||||
var dayInSemester =
|
||||
planner.LocalCourse?.DaysOfWeek.Contains(notNullDay) ?? false
|
||||
isClassDay
|
||||
&& date < planner.LocalCourse.EndDate
|
||||
&& date > planner.LocalCourse.StartDate;
|
||||
|
||||
var totalClasses = dayInSemester ? $"bg-light-subtle text-light {baseClasses}" : baseClasses;
|
||||
|
||||
var totalClasses = dayInSemester ? $"bg-light-subtle text-light " + baseClasses : baseClasses;
|
||||
|
||||
return totalClasses;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
public record RubricItem(int Points, string Label);
|
||||
public record RubricItem
|
||||
{
|
||||
public string Id { get; set; } = "";
|
||||
public string Label { get; set; } = "";
|
||||
public int Points { get; set; } = 0;
|
||||
}
|
||||
|
||||
public enum SubmissionType
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user