mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
added quiz support, improved assignment description and rubric support
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
Description = assignmentContext.Assignment.Description;
|
||||
description = assignmentContext.Assignment.Description;
|
||||
descriptionForPreview = description;
|
||||
TemplateId = assignmentContext.Assignment.TemplateId;
|
||||
UseTemplate = TemplateId != null && TemplateId != "";
|
||||
VariableValues = assignmentContext.Assignment.TemplateVariables;
|
||||
@@ -27,25 +28,7 @@
|
||||
}
|
||||
|
||||
private string description { get; set; } = default!;
|
||||
public string Description
|
||||
{
|
||||
get => description;
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
if (description != string.Empty)
|
||||
{
|
||||
if(assignmentContext.Assignment != null)
|
||||
{
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Description = description
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string descriptionForPreview { get; set; } = default!;
|
||||
public bool? UseTemplate { get; set; } = null;
|
||||
|
||||
public string? TemplateId { get; set; }
|
||||
@@ -58,9 +41,21 @@
|
||||
.AssignmentTemplates
|
||||
.FirstOrDefault(t => t.Id == TemplateId);
|
||||
|
||||
private void saveDescription(ChangeEventArgs e)
|
||||
private void handleNewDescription(ChangeEventArgs e)
|
||||
{
|
||||
|
||||
var newDescription = e.Value?.ToString();
|
||||
if (newDescription != string.Empty)
|
||||
{
|
||||
descriptionForPreview = newDescription;
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Description = newDescription
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTemplateId(ChangeEventArgs e)
|
||||
@@ -68,15 +63,15 @@
|
||||
if(assignmentContext.Assignment != null)
|
||||
{
|
||||
var newTemplateId = e.Value?.ToString();
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Description = e.Value?.ToString() ?? ""
|
||||
TemplateId = newTemplateId
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
}
|
||||
}
|
||||
|
||||
private MarkupString preview { get => (MarkupString) Markdown.ToHtml(Description); }
|
||||
private MarkupString preview { get => (MarkupString)Markdown.ToHtml(descriptionForPreview); }
|
||||
|
||||
}
|
||||
|
||||
@@ -167,11 +162,11 @@
|
||||
id="description"
|
||||
class="form-control"
|
||||
rows=12
|
||||
@bind="Description"
|
||||
@bind:event="oninput"
|
||||
@bind="description"
|
||||
@oninput="handleNewDescription"
|
||||
/>
|
||||
</div>
|
||||
<div class="col" @key="Description">
|
||||
<div class="col" @key="descriptionForPreview">
|
||||
@(preview)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,6 +12,20 @@
|
||||
public Action MoveUp { get; set; } = default!;
|
||||
[Parameter, EditorRequired]
|
||||
public Action MoveDown { get; set; } = default!;
|
||||
|
||||
private int points { get; set; }
|
||||
private string label { get; set; }
|
||||
private string lastRubricItemId { get; set; }
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if(RubricItem.Id != lastRubricItemId)
|
||||
{
|
||||
lastRubricItemId = RubricItem.Id;
|
||||
points = RubricItem.Points;
|
||||
label = RubricItem.Label;
|
||||
}
|
||||
}
|
||||
|
||||
private void editItem(string label, int points)
|
||||
{
|
||||
var newRubricItem = RubricItem with
|
||||
@@ -39,7 +53,7 @@
|
||||
id="rubricLabel"
|
||||
name="rubricLabel"
|
||||
@oninput="@(e => editItem(e.Value?.ToString() ?? "", RubricItem.Points))"
|
||||
value="@RubricItem.Label"
|
||||
@bind="label"
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
@@ -57,7 +71,7 @@
|
||||
RubricItem.Label,
|
||||
int.Parse(e.Value?.ToString() != "" ? e.Value?.ToString() ?? "0" : "0"))
|
||||
)"
|
||||
value="@RubricItem.Points"
|
||||
@bind="points"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user