mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
got assignment template variables and replacement working
This commit is contained in:
@@ -134,7 +134,23 @@
|
||||
<div class="card-text">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@Assignment.description
|
||||
@if(Assignment.use_template)
|
||||
{
|
||||
var template = planner.LocalCourse?.AssignmentTemplates.First((t) => t.Id == Assignment.template_id);
|
||||
if(template == null)
|
||||
{
|
||||
System.Console.WriteLine($"Could not find template fof assignment, {Assignment.template_id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var html = AssignmentTemplate.GetHtml(template, Assignment);
|
||||
@((MarkupString) html)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@Assignment.description
|
||||
}
|
||||
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
public bool UseTemplate { get; set; }
|
||||
[Parameter]
|
||||
public string? TemplateId { get; set; }
|
||||
[Parameter]
|
||||
public Dictionary<string, string> VariableValues { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> DescriptionChanged { get; set; }
|
||||
@@ -19,12 +21,14 @@
|
||||
[Parameter]
|
||||
public EventCallback<string?> TemplateIdChanged { get; set; }
|
||||
|
||||
private string selectedTemplateId { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<Dictionary<string, string>> VariableValuesChanged { get; set; }
|
||||
|
||||
private AssignmentTemplate? selectedTemplate =>
|
||||
planner
|
||||
.LocalCourse?
|
||||
.AssignmentTemplates
|
||||
.FirstOrDefault(t => t.Id == selectedTemplateId);
|
||||
.FirstOrDefault(t => t.Id == TemplateId);
|
||||
|
||||
}
|
||||
|
||||
@@ -55,8 +59,14 @@
|
||||
<div class="col-auto text-center">
|
||||
<form @onsubmit:preventDefault="true">
|
||||
<label for="templateSelect">Templates</label>
|
||||
<select id="templateSelect" class="form-select" @bind="selectedTemplateId">
|
||||
<option></option>
|
||||
<select
|
||||
id="templateSelect"
|
||||
class="form-select"
|
||||
value="@TemplateId"
|
||||
@onchange="async (e) =>
|
||||
await TemplateIdChanged.InvokeAsync(e.Value?.ToString())"
|
||||
>
|
||||
<option value=""></option>
|
||||
@foreach (var template in planner.LocalCourse.AssignmentTemplates)
|
||||
{
|
||||
<option value="@template.Id">@template.Name</option>
|
||||
@@ -79,6 +89,16 @@
|
||||
</label>
|
||||
<input
|
||||
class="form-control"
|
||||
value="@VariableValues.GetValueOrDefault(variable, String.Empty)"
|
||||
@oninput="async (e) =>
|
||||
{
|
||||
var newValue = e.Value?.ToString() ?? String.Empty;
|
||||
var newDictionary = new Dictionary<string, string>(VariableValues);
|
||||
newDictionary[variable] = newValue;
|
||||
|
||||
await VariableValuesChanged.InvokeAsync(newDictionary);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
.Where(r => !r.Label.Contains(RubricItem.extraCredit))
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
|
||||
var newAssignment = Assignment with
|
||||
{
|
||||
name=name,
|
||||
@@ -117,6 +118,7 @@
|
||||
@bind-Description="description"
|
||||
@bind-UseTemplate="useTemplate"
|
||||
@bind-TemplateId="templateId"
|
||||
@bind-VariableValues="templateVariables"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user