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