mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
before i get in a deeper hole
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
{
|
||||
planner.StateHasChanged -= reload;
|
||||
}
|
||||
private Modal? assignmentEditorModal { get; set; }
|
||||
private bool showAll { get; set; } = false;
|
||||
|
||||
private void dropOnDate(DateTime dropDate)
|
||||
@@ -134,18 +133,15 @@
|
||||
role="button"
|
||||
>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<h4 class="text-center">
|
||||
<div class="card-body p-0">
|
||||
<div class="card-title pt-2 px-2 m-0">
|
||||
<div class="row mx-1">
|
||||
<div class="col offset-2 offset-lg-1 ">
|
||||
<h4 class="text-center m-0">
|
||||
@Assignment.name
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<div class="col-2 col-lg-1 text-end">
|
||||
@if(isSyncedWithCanvas)
|
||||
{
|
||||
@if(planner.LocalCourse != null
|
||||
@@ -167,23 +163,15 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>Not Synced with Canvas</div>
|
||||
<SyncIcon />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(!showAll)
|
||||
{
|
||||
<div class="card-text overflow-hidden" style="max-height: 5rem;">
|
||||
@* @if(Assignment.use_template)
|
||||
{
|
||||
var html = Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates);
|
||||
@((MarkupString) html)
|
||||
}
|
||||
else
|
||||
{
|
||||
@Assignment.description
|
||||
} *@
|
||||
<div class="card-text overflow-hidden p-2" style="max-height: 5rem;">
|
||||
<div>Points: @Assignment.points_possible</div>
|
||||
<div>Due At: @Assignment.due_at</div>
|
||||
</div>
|
||||
@@ -191,45 +179,25 @@
|
||||
else
|
||||
{
|
||||
<div class="card-text">
|
||||
@if(Assignment.use_template)
|
||||
{
|
||||
var html = Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates);
|
||||
@((MarkupString) html)
|
||||
}
|
||||
else
|
||||
{
|
||||
@Assignment.description
|
||||
}
|
||||
|
||||
<hr>
|
||||
<div>Points: @Assignment.points_possible</div>
|
||||
<div>Due At: @Assignment.due_at</div>
|
||||
<div>Lock At: @Assignment.lock_at</div>
|
||||
<br>
|
||||
<h5>
|
||||
Rubric
|
||||
</h5>
|
||||
@foreach(var rubricItem in Assignment.rubric)
|
||||
{
|
||||
<div class="row m-0">
|
||||
<div class="col border-end my-auto">
|
||||
@rubricItem.Label
|
||||
</div>
|
||||
<div class="col-2 my-auto">
|
||||
@rubricItem.Points
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<br>
|
||||
<div>Submission Types:</div>
|
||||
<ul>
|
||||
@foreach(var type in Assignment.submission_types)
|
||||
{
|
||||
<li>
|
||||
@type
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<div class="px-3 py-1 bg-dark-subtle my-1">
|
||||
|
||||
@((MarkupString) @Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates))
|
||||
</div>
|
||||
|
||||
<section class="px-3">
|
||||
<div>Points: @Assignment.points_possible</div>
|
||||
<div>Due At: @Assignment.due_at</div>
|
||||
<div>Lock At: @Assignment.lock_at</div>
|
||||
<div>Submission Types:</div>
|
||||
<ul>
|
||||
@foreach(var type in Assignment.submission_types)
|
||||
{
|
||||
<li>
|
||||
@type
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -237,25 +205,45 @@
|
||||
@if(!showAll)
|
||||
{
|
||||
<div
|
||||
class="text-center"
|
||||
class="text-center fs-3 fw-bold lh-1 text-primary"
|
||||
role="button"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true"
|
||||
@onclick="() => showAll = true"
|
||||
>
|
||||
...
|
||||
<svg
|
||||
width="30"
|
||||
height="30"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 10a2 2 0 11-4.001-.001A2 2 0 016 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0112 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0118 10z"
|
||||
fill="var(--bs-primary)"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div
|
||||
class="text-center"
|
||||
class="text-center fs-3 fw-bold lh-1 text-primary"
|
||||
role="button"
|
||||
@onclick:preventDefault="true"
|
||||
@onclick:stopPropagation="true"
|
||||
@onclick="() => showAll = false"
|
||||
>
|
||||
...
|
||||
<svg
|
||||
width="30"
|
||||
height="30"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 10a2 2 0 11-4.001-.001A2 2 0 016 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0112 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0118 10z"
|
||||
fill="var(--bs-primary)"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -267,5 +255,4 @@
|
||||
Assignment="Assignment"
|
||||
Show="showUpdateForm"
|
||||
OnHide="@(() => showUpdateForm = false)"
|
||||
Module="Module"
|
||||
/>
|
||||
@@ -1,3 +1,4 @@
|
||||
@using Markdig
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
.LocalCourse?
|
||||
.AssignmentTemplates
|
||||
.FirstOrDefault(t => t.Id == TemplateId);
|
||||
public string Preview => Markdown.ToHtml(Description);
|
||||
|
||||
}
|
||||
|
||||
@@ -109,17 +111,35 @@
|
||||
}
|
||||
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)"
|
||||
/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label
|
||||
for="description"
|
||||
class="form-label"
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
HTML Preview
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<textarea
|
||||
id="description"
|
||||
class="form-control"
|
||||
value="@Description"
|
||||
rows=12
|
||||
@oninput="async (e) =>
|
||||
await DescriptionChanged.InvokeAsync(e.Value?.ToString() ?? String.Empty)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
@((MarkupString) Preview)
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
@@ -94,6 +92,11 @@
|
||||
rubric = newRubric;
|
||||
StateHasChanged();
|
||||
}
|
||||
private void SetTypes(IEnumerable<string> newTypes)
|
||||
{
|
||||
submissionTypes = newTypes;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
|
||||
@@ -139,7 +142,7 @@
|
||||
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
|
||||
<SubmissionTypeSelector
|
||||
Types="submissionTypes"
|
||||
SetTypes="(newTypes) => submissionTypes = newTypes"
|
||||
SetTypes="SetTypes"
|
||||
/>
|
||||
</form>
|
||||
</Body>
|
||||
|
||||
@@ -22,6 +22,13 @@
|
||||
);
|
||||
StateHasChanged();
|
||||
}
|
||||
private void removeItem()
|
||||
{
|
||||
SetRubric(
|
||||
Rubric.Take(Rubric.Count() - 1)
|
||||
);
|
||||
StateHasChanged();
|
||||
}
|
||||
private void editItem(RubricItem newItem)
|
||||
{
|
||||
var newRubric = Rubric.Select(i => i.Id == newItem.Id ? newItem : i);
|
||||
@@ -71,6 +78,14 @@
|
||||
</ul>
|
||||
|
||||
<div class="text-end my-1">
|
||||
<button
|
||||
@onclick:preventDefault="true"
|
||||
@onclick="removeItem"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"
|
||||
>
|
||||
- rubric item
|
||||
</button>
|
||||
<button
|
||||
@onclick:preventDefault="true"
|
||||
@onclick="addItem"
|
||||
|
||||
@@ -2,8 +2,16 @@
|
||||
|
||||
@code
|
||||
{
|
||||
private IEnumerable<string> _types { get; set; } = Enumerable.Empty<string>();
|
||||
[Parameter, EditorRequired]
|
||||
public IEnumerable<string> Types { get; set; } = Enumerable.Empty<string>();
|
||||
public IEnumerable<string> Types {
|
||||
get => _types;
|
||||
set
|
||||
{
|
||||
_types = value;
|
||||
renderKey++;
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<IEnumerable<string>> SetTypes { get; set; } = (_) => {};
|
||||
@@ -11,36 +19,47 @@
|
||||
{
|
||||
return type.ToString().Replace("_", "") + "switch";
|
||||
}
|
||||
|
||||
private bool discussionIsSelected
|
||||
{
|
||||
get => Types.FirstOrDefault(
|
||||
t => t == SubmissionType.discussion_topic
|
||||
) != null;
|
||||
}
|
||||
private int renderKey {get; set; } = 1;
|
||||
}
|
||||
|
||||
<h5>Submission Types</h5>
|
||||
<div class="row">
|
||||
<div class="row" @key="Types">
|
||||
|
||||
@foreach (var submissionType in SubmissionType.AllTypes)
|
||||
{
|
||||
<div class="col-4">
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
id="@getLabel(submissionType)"
|
||||
checked="@Types.Contains(submissionType)"
|
||||
@onchange="(e) => {
|
||||
var isChecked = (bool)(e.Value ?? false);
|
||||
if(isChecked)
|
||||
SetTypes(Types.Append(submissionType));
|
||||
else
|
||||
SetTypes(Types.Where(t => t != submissionType));
|
||||
}"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="@getLabel(submissionType)"
|
||||
>
|
||||
@submissionType
|
||||
</label>
|
||||
@foreach (var submissionType in SubmissionType.AllTypes)
|
||||
{
|
||||
var isDiscussion = submissionType == SubmissionType.discussion_topic;
|
||||
var allowedToBeChecked = !discussionIsSelected || isDiscussion;
|
||||
<div class="col-4">
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
id="@getLabel(submissionType)"
|
||||
checked="@(Types.Contains(submissionType) && allowedToBeChecked)"
|
||||
@onchange="(e) => {
|
||||
var isChecked = (bool)(e.Value ?? false);
|
||||
if(isChecked)
|
||||
SetTypes(Types.Append(submissionType));
|
||||
else
|
||||
SetTypes(Types.Where(t => t != submissionType));
|
||||
}"
|
||||
disabled="@(discussionIsSelected && !isDiscussion)"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="@getLabel(submissionType)"
|
||||
>
|
||||
@submissionType
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -1,75 +0,0 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Required]
|
||||
[StringLength(50, ErrorMessage = "Name too long (50 character limit).")]
|
||||
private string Name { get; set; } = "";
|
||||
|
||||
private Modal? modal { get; set; }
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
System.Console.WriteLine("new assignment");
|
||||
var newAssignment = new LocalAssignment
|
||||
{
|
||||
id = Guid.NewGuid().ToString(),
|
||||
name = Name,
|
||||
description = "",
|
||||
lock_at_due_date = true,
|
||||
rubric = new RubricItem[] { },
|
||||
lock_at = null,
|
||||
due_at = DateTime.Now,
|
||||
points_possible = 10,
|
||||
submission_types = new string[] { SubmissionType.online_text_entry }
|
||||
};
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Append(newAssignment)
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
modal?.Hide();
|
||||
}
|
||||
}
|
||||
<button
|
||||
class="btn btn-outline-secondary"
|
||||
@onclick="() => modal?.Show()"
|
||||
>
|
||||
New Assignment
|
||||
</button>
|
||||
|
||||
<Modal @ref="modal">
|
||||
<Title>New Assignment</Title>
|
||||
<Body>
|
||||
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
||||
<label for="Assignment Name">Name</label>
|
||||
<input id="moduleName" class="form-control" @bind="Name" />
|
||||
</form>
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
@onclick="submitHandler"
|
||||
>
|
||||
Save changes
|
||||
</button>
|
||||
</Footer>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user