mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
working on submission types (need rubric as well)
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
AssignmentModal?.Show();
|
||||
name = assignmentContext.Assignment.Name;
|
||||
lockAtDueDate = assignmentContext.Assignment.LockAtDueDate;
|
||||
rubric = assignmentContext.Assignment.Rubric;
|
||||
submissionTypes = assignmentContext.Assignment.SubmissionTypes;
|
||||
}
|
||||
this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
@@ -33,25 +31,15 @@
|
||||
public Modal? AssignmentModal { get; set; } = null;
|
||||
private string name { get; set; } = String.Empty;
|
||||
private bool lockAtDueDate { get; set; }
|
||||
private IEnumerable<RubricItem> rubric { get; set; } = Enumerable.Empty<RubricItem>();
|
||||
private IEnumerable<string> submissionTypes { get; set; } = Enumerable.Empty<string>();
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var totalRubricPoints = rubric
|
||||
.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,
|
||||
};
|
||||
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
@@ -60,18 +48,6 @@
|
||||
assignmentContext.Assignment = null;
|
||||
}
|
||||
|
||||
|
||||
private void updateRubric(IEnumerable<RubricItem> newRubric)
|
||||
{
|
||||
rubric = newRubric;
|
||||
StateHasChanged();
|
||||
}
|
||||
private void SetTypes(IEnumerable<string> newTypes)
|
||||
{
|
||||
submissionTypes = newTypes;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task HandleDelete()
|
||||
{
|
||||
if (planner.LocalCourse != null && assignmentContext.Assignment != null)
|
||||
@@ -173,7 +149,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<RubricEditor />
|
||||
<SubmissionTypeSelector Types="submissionTypes" SetTypes="SetTypes" />
|
||||
<SubmissionTypeSelector />
|
||||
</form>
|
||||
}
|
||||
</Body>
|
||||
|
||||
@@ -28,9 +28,14 @@
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var totalRubricPoints = rubric
|
||||
.Where(r => !r.Label.Contains(RubricItem.extraCredit))
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Rubric = rubric
|
||||
Rubric = rubric,
|
||||
PointsPossible = totalRubricPoints,
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
StateHasChanged();
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
@using System.Reflection
|
||||
@inject AssignmentEditorContext assignmentContext
|
||||
|
||||
@code
|
||||
{
|
||||
private IEnumerable<string> _types { get; set; } = Enumerable.Empty<string>();
|
||||
[Parameter, EditorRequired]
|
||||
public IEnumerable<string> Types { get; set; } = Enumerable.Empty<string>();
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<IEnumerable<string>> SetTypes { get; set; } = (_) => {};
|
||||
protected override void OnParametersSet()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (!Types.SequenceEqual(_types))
|
||||
{
|
||||
_types = Types;
|
||||
renderKey++;
|
||||
}
|
||||
assignmentContext.StateHasChanged += reload;
|
||||
}
|
||||
private void reload()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
types = assignmentContext.Assignment.SubmissionTypes;
|
||||
|
||||
}
|
||||
this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
assignmentContext.StateHasChanged -= reload;
|
||||
}
|
||||
private IEnumerable<string> types { get; set; } = Enumerable.Empty<string>();
|
||||
|
||||
private string getLabel(string type)
|
||||
{
|
||||
@@ -24,15 +29,26 @@
|
||||
|
||||
private bool discussionIsSelected
|
||||
{
|
||||
get => Types.FirstOrDefault(
|
||||
get => types.FirstOrDefault(
|
||||
t => t == SubmissionType.DISCUSSION_TOPIC
|
||||
) != null;
|
||||
}
|
||||
private int renderKey {get; set; } = 1;
|
||||
private void saveTypes(IEnumerable<string> newTypes)
|
||||
{
|
||||
if(assignmentContext.Assignment != null)
|
||||
{
|
||||
assignmentContext.SaveAssignment(assignmentContext.Assignment with
|
||||
{
|
||||
SubmissionTypes = newTypes
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<h5>Submission Types</h5>
|
||||
<div class="row" @key="Types">
|
||||
<div class="row" @key="types">
|
||||
|
||||
@foreach (var submissionType in SubmissionType.AllTypes)
|
||||
{
|
||||
@@ -45,13 +61,13 @@
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
id="@getLabel(submissionType)"
|
||||
checked="@(Types.Contains(submissionType) && allowedToBeChecked)"
|
||||
checked="@(types.Contains(submissionType) && allowedToBeChecked)"
|
||||
@onchange="(e) => {
|
||||
var isChecked = (bool)(e.Value ?? false);
|
||||
if(isChecked)
|
||||
SetTypes(Types.Append(submissionType));
|
||||
saveTypes(types.Append(submissionType));
|
||||
else
|
||||
SetTypes(Types.Where(t => t != submissionType));
|
||||
saveTypes(types.Where(t => t != submissionType));
|
||||
}"
|
||||
disabled="@(discussionIsSelected && !isDiscussion)"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user