mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
adding template description fields to assignment form
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
|
||||
<link href="css/site.css" rel="stylesheet" />
|
||||
<link href="Management.Web.styles.css" rel="stylesheet" />
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,600&display=swap" rel="stylesheet">
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
|
||||
</head>
|
||||
|
||||
@@ -39,15 +39,18 @@
|
||||
get => terms?.FirstOrDefault(t => t.Id == selectedTermId);
|
||||
}
|
||||
private bool loading = false;
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(planner.LocalCourse != null && planner.LocalCourse.CanvasId != null)
|
||||
if (firstRender)
|
||||
{
|
||||
loading = true;
|
||||
ulong id = planner.LocalCourse?.CanvasId ?? throw new Exception("wtf how did i get here");
|
||||
var canvasCourse = await canvas.GetCourse(id);
|
||||
terms = await canvas.GetCurrentTermsFor(canvasCourse.StartAt);
|
||||
loading = false;
|
||||
if(planner.LocalCourse != null && planner.LocalCourse.CanvasId != null)
|
||||
{
|
||||
loading = true;
|
||||
ulong id = planner.LocalCourse?.CanvasId ?? throw new Exception("wtf how did i get here");
|
||||
var canvasCourse = await canvas.GetCourse(id);
|
||||
terms = await canvas.GetCurrentTermsFor(canvasCourse.StartAt);
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using CanvasModel.EnrollmentTerms
|
||||
@using Management.Web.Shared.Components
|
||||
@using Management.Web.Shared.Semester
|
||||
@using CanvasModel.Courses
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using Management.Web.Shared.Components
|
||||
@using Management.Web.Shared.Module.Assignment.AssignmentForm
|
||||
|
||||
@inject AssignmentDragContainer dragContainer
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter]
|
||||
public string Description { get; set; } = default!;
|
||||
[Parameter]
|
||||
public bool UseTemplate { get; set; }
|
||||
[Parameter]
|
||||
public string? TemplateId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> DescriptionChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> UseTemplateChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string?> TemplateIdChanged { get; set; }
|
||||
|
||||
private string selectedTemplateId { get; set; }
|
||||
private AssignmentTemplate? selectedTemplate =>
|
||||
planner
|
||||
.LocalCourse?
|
||||
.AssignmentTemplates
|
||||
.FirstOrDefault(t => t.Id == selectedTemplateId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
id="useTemplateForDescription"
|
||||
checked="@UseTemplate"
|
||||
@onchange="async (e) =>
|
||||
await UseTemplateChanged.InvokeAsync((bool)(e.Value ?? false))"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="useTemplateForDescription"
|
||||
>
|
||||
use template for description
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@if(UseTemplate)
|
||||
{
|
||||
@if(planner.LocalCourse != null)
|
||||
{
|
||||
<div class="row justify-content-around">
|
||||
<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>
|
||||
@foreach (var template in planner.LocalCourse.AssignmentTemplates)
|
||||
{
|
||||
<option value="@template.Id">@template.Name</option>
|
||||
}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
VARIABLES:
|
||||
@if(selectedTemplate != null)
|
||||
{
|
||||
var variables = AssignmentTemplate.GetVariables(selectedTemplate.Markdown);
|
||||
@foreach(var variable in variables)
|
||||
{
|
||||
<div class="my-1">
|
||||
<label
|
||||
class="form-label"
|
||||
>
|
||||
@variable
|
||||
</label>
|
||||
<input
|
||||
class="form-control"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<label
|
||||
for="description"
|
||||
class="form-label"
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
class="form-control"
|
||||
value="@Description"
|
||||
@oninput="async (e) =>
|
||||
await DescriptionChanged.InvokeAsync(e.Value?.ToString() ?? String.Empty)"
|
||||
/>
|
||||
}
|
||||
@@ -23,6 +23,10 @@
|
||||
public Action OnHide { get; set; } = () => { };
|
||||
public Modal AssignmentModal { get; set; } = default!;
|
||||
|
||||
private bool useTemplate { get; set; } = false;
|
||||
private string? templateId { get; set; }
|
||||
public Dictionary<string, string> templateVariables { get; set; } =
|
||||
new Dictionary<string, string>();
|
||||
private string description { get; set; } = String.Empty;
|
||||
private string name { get; set; } = String.Empty;
|
||||
private bool lockAtDueDate { get; set; }
|
||||
@@ -40,6 +44,9 @@
|
||||
lockAtDueDate = Assignment.lock_at_due_date;
|
||||
rubric = Assignment.rubric;
|
||||
submissionTypes = Assignment.submission_types;
|
||||
templateId = Assignment.template_id;
|
||||
useTemplate = Assignment.use_template;
|
||||
templateVariables = Assignment.template_variables;
|
||||
}
|
||||
|
||||
private void submitHandler()
|
||||
@@ -56,6 +63,9 @@
|
||||
rubric=rubric,
|
||||
points_possible=totalRubricPoints,
|
||||
submission_types=submissionTypes,
|
||||
use_template=useTemplate,
|
||||
template_id=templateId,
|
||||
template_variables=templateVariables,
|
||||
};
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
@@ -103,16 +113,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="m-1">
|
||||
<label
|
||||
for="description"
|
||||
class="form-label"
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
class="form-control"
|
||||
@bind="description"
|
||||
<AssignmentDescriptionEditor
|
||||
@bind-Description="description"
|
||||
@bind-UseTemplate="useTemplate"
|
||||
@bind-TemplateId="templateId"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
get { return _selectedTemplateId; }
|
||||
set { _selectedTemplateId = value; }
|
||||
}
|
||||
|
||||
|
||||
private AssignmentTemplate? selectedTemplate =>
|
||||
planner
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
||||
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
|
||||
|
||||
html, body {
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
font-family: 'DM Sans', sans-serif;
|
||||
}
|
||||
|
||||
h1:focus {
|
||||
|
||||
@@ -26,6 +26,10 @@ public record LocalAssignment
|
||||
public ulong? canvasId = null;
|
||||
public string name { get; init; } = "";
|
||||
public string description { get; init; } = "";
|
||||
public bool use_template { get; init; } = false;
|
||||
public string? template_id { get; init; } = string.Empty;
|
||||
public Dictionary<string, string> template_variables { get; init; } =
|
||||
new Dictionary<string, string>();
|
||||
public bool lock_at_due_date { get; init; }
|
||||
public IEnumerable<RubricItem> rubric { get; init; } = new RubricItem[] { };
|
||||
public DateTime? lock_at { get; init; }
|
||||
|
||||
Reference in New Issue
Block a user