mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
peace nirvana and no yellow warning lines in my console
This commit is contained in:
@@ -143,7 +143,7 @@
|
||||
private async Task deleteFromCanvas()
|
||||
{
|
||||
if (assignmentInCanvas == null
|
||||
|| planner?.LocalCourse.Settings.CanvasId == null
|
||||
|| planner?.LocalCourse?.Settings.CanvasId == null
|
||||
|| assignmentContext.Assignment == null
|
||||
)
|
||||
return;
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private MarkupString preview { get => (MarkupString)Markdown.ToHtml(assignmentContext.Assignment.Description); }
|
||||
private MarkupString preview { get => (MarkupString)Markdown.ToHtml(assignmentContext?.Assignment?.Description ?? ""); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
@code
|
||||
{
|
||||
private int rubricReloadKey = 0;
|
||||
|
||||
private string? error { get; set; } = null;
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -24,39 +22,40 @@
|
||||
assignmentContext.StateHasChanged -= reload;
|
||||
}
|
||||
|
||||
private int requiredPoints => assignmentContext.Assignment.Rubric.Where(r => !r.IsExtraCredit).Select(r => r.Points).Sum();
|
||||
private int extraCreditPoints => assignmentContext.Assignment.Rubric.Where(r => r.IsExtraCredit).Select(r => r.Points).Sum();
|
||||
private int requiredPoints => assignmentContext?.Assignment?.Rubric.Where(r => !r.IsExtraCredit).Select(r => r.Points).Sum() ?? 0;
|
||||
private int extraCreditPoints => assignmentContext?.Assignment?.Rubric.Where(r => r.IsExtraCredit).Select(r => r.Points).Sum() ?? 0;
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<h4 class="text-center">Rubric</h4>
|
||||
</div>
|
||||
|
||||
@if (error != null)
|
||||
@if(assignmentContext != null)
|
||||
{
|
||||
<p class="text-danger text-truncate">Error: @error</p>
|
||||
}
|
||||
<div class="row">
|
||||
<h4 class="text-center">Rubric</h4>
|
||||
</div>
|
||||
|
||||
@if (error != null)
|
||||
{
|
||||
<p class="text-danger text-truncate">Error: @error</p>
|
||||
}
|
||||
|
||||
<div class="row border-bottom">
|
||||
<div class="col-6 text-end">Label</div>
|
||||
<div class="col-3 text-center">Points</div>
|
||||
<div class="col-3 text-center">Extra Credit</div>
|
||||
</div>
|
||||
@foreach (var item in assignmentContext.Assignment.Rubric)
|
||||
{
|
||||
<div class="row border-bottom">
|
||||
<div class="col-6 text-end">@item.Label</div>
|
||||
<div class="col-3 text-center">@item.Points</div>
|
||||
<div class="col-3 text-center">@item.IsExtraCredit</div>
|
||||
<div class="col-6 text-end">Label</div>
|
||||
<div class="col-3 text-center">Points</div>
|
||||
<div class="col-3 text-center">Extra Credit</div>
|
||||
</div>
|
||||
}
|
||||
<div class="text-end">
|
||||
<div>
|
||||
Required Points: @requiredPoints
|
||||
@foreach (var item in assignmentContext?.Assignment?.Rubric ?? [])
|
||||
{
|
||||
<div class="row border-bottom">
|
||||
<div class="col-6 text-end">@item.Label</div>
|
||||
<div class="col-3 text-center">@item.Points</div>
|
||||
<div class="col-3 text-center">@item.IsExtraCredit</div>
|
||||
</div>
|
||||
}
|
||||
<div class="text-end">
|
||||
<div>
|
||||
Required Points: @requiredPoints
|
||||
</div>
|
||||
<div>
|
||||
Extra Credit Points @extraCreditPoints
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
Extra Credit Points @extraCreditPoints
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject CoursePlanner planner
|
||||
@inject AssignmentEditorContext assignmentContext
|
||||
|
||||
@code
|
||||
{
|
||||
private IEnumerable<RubricItem> rubric { get; set; } = Array.Empty<RubricItem>();
|
||||
private int rubricReloadKey = 0;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
assignmentContext.StateHasChanged += reload;
|
||||
reload();
|
||||
}
|
||||
private void reload()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
rubric = assignmentContext.Assignment.Rubric;
|
||||
}
|
||||
this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
assignmentContext.StateHasChanged -= reload;
|
||||
}
|
||||
|
||||
private void save()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var newAssignment = assignmentContext.Assignment with
|
||||
{
|
||||
Rubric = rubric,
|
||||
};
|
||||
assignmentContext.SaveAssignment(newAssignment);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
private void addItem()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
rubric = rubric.Append(new RubricItem
|
||||
{
|
||||
Label = "",
|
||||
Points = 0
|
||||
});
|
||||
}
|
||||
}
|
||||
private void removeItem()
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
rubric = rubric.Take(rubric.Count() - 1);
|
||||
save();
|
||||
}
|
||||
}
|
||||
private void editItem(RubricItem newItem, int index)
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
rubric = rubric.Select((r, i) => i == index ? newItem : r);
|
||||
save();
|
||||
}
|
||||
}
|
||||
private void MoveUp(RubricItem item)
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var rubricList = rubric.ToList();
|
||||
var index = rubricList.IndexOf(item);
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
var previous = rubricList[index - 1];
|
||||
rubricList[index - 1] = item;
|
||||
rubricList[index] = previous;
|
||||
rubric = rubricList;
|
||||
save();
|
||||
}
|
||||
rubricReloadKey++;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
private void MoveDown(RubricItem item)
|
||||
{
|
||||
if (assignmentContext.Assignment != null)
|
||||
{
|
||||
var rubricList = rubric.ToList();
|
||||
var index = rubricList.IndexOf(item);
|
||||
|
||||
if (index < rubricList.Count())
|
||||
{
|
||||
var next = rubricList[index + 1];
|
||||
rubricList[index + 1] = item;
|
||||
rubricList[index] = next;
|
||||
rubric = rubricList;
|
||||
save();
|
||||
}
|
||||
rubricReloadKey++;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int requiredPoints => rubric.Where(r => !r.IsExtraCredit).Select(r => r.Points).Sum();
|
||||
private int extraCreditPoints => rubric.Where(r => r.IsExtraCredit).Select(r => r.Points).Sum();
|
||||
}
|
||||
|
||||
<br>
|
||||
<div class="row">
|
||||
|
||||
<div class="col offset-3">
|
||||
<h4 class="text-center">Rubric</h4>
|
||||
</div>
|
||||
|
||||
<div class=" col-3 text-end my-1">
|
||||
<button
|
||||
@onclick:preventDefault="true"
|
||||
@onclick="addItem"
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
>
|
||||
+ rubric item
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="list-group">
|
||||
@foreach (var (rubricItem, index) in rubric.Select((r, i) => (r, i)))
|
||||
{
|
||||
<RubricEditorItem
|
||||
@key="@($"index-{index}-key-{rubricReloadKey}-extra-credit-{rubricItem.IsExtraCredit}")"
|
||||
RubricItem="rubricItem"
|
||||
OnUpdate="(newItem) => editItem(newItem, index)"
|
||||
MoveUp="() => MoveUp(rubricItem)"
|
||||
MoveDown="() => MoveDown(rubricItem)"
|
||||
/>
|
||||
}
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div>
|
||||
Requred Points: @requiredPoints
|
||||
</div>
|
||||
<div>
|
||||
Extra Credit Points @extraCreditPoints
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<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"
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
>
|
||||
+ rubric item
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,137 +0,0 @@
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter, EditorRequired]
|
||||
public RubricItem RubricItem { get; set; } = default!;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<RubricItem> OnUpdate { get; set; } = default!;
|
||||
[Parameter, EditorRequired]
|
||||
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 bool firstLoad = true;
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if(firstLoad)
|
||||
{
|
||||
firstLoad = false;
|
||||
points = RubricItem.Points;
|
||||
label = RubricItem.Label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void editItem(string label, int points)
|
||||
{
|
||||
var newRubricItem = RubricItem with
|
||||
{
|
||||
Label = label,
|
||||
Points = points
|
||||
};
|
||||
OnUpdate(newRubricItem);
|
||||
}
|
||||
}
|
||||
|
||||
<li
|
||||
class="list-group-item"
|
||||
>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label
|
||||
for="rubricLabel"
|
||||
class="form-label"
|
||||
>
|
||||
Label
|
||||
</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="rubricLabel"
|
||||
name="rubricLabel"
|
||||
@oninput="@(e => editItem(e.Value?.ToString() ?? "", RubricItem.Points))"
|
||||
@bind="label"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label
|
||||
for="rubricPoints"
|
||||
class="form-label"
|
||||
>
|
||||
Points
|
||||
</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="rubricPoints"
|
||||
name="rubricPoints"
|
||||
@oninput="@(e => editItem(
|
||||
RubricItem.Label,
|
||||
int.Parse(e.Value?.ToString() != "" ? e.Value?.ToString() ?? "0" : "0"))
|
||||
)"
|
||||
@bind="points"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="flexCheckDefault"
|
||||
>
|
||||
Extra Credit
|
||||
</label>
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
checked="@RubricItem.Label.Contains(RubricItem.extraCredit)"
|
||||
@oninput="@(e => {
|
||||
bool value = (bool) (e.Value ?? false);
|
||||
var newLabel = value
|
||||
? RubricItem.extraCredit + RubricItem.Label
|
||||
: RubricItem.Label.Replace(RubricItem.extraCredit, "");
|
||||
editItem(newLabel, RubricItem.Points);
|
||||
})"
|
||||
id="extraCredit"
|
||||
name="extraCredit"
|
||||
role="switch"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div >
|
||||
<svg
|
||||
width="2em"
|
||||
height="2em"
|
||||
viewBox="-0.5 0 25 25"
|
||||
fill="none"
|
||||
stroke="rgb(173, 181, 189)"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
role="button"
|
||||
@onclick="MoveUp"
|
||||
>
|
||||
<path d="M8 13.8599L10.87 10.8C11.0125 10.6416 11.1868 10.5149 11.3815 10.4282C11.5761 10.3415 11.7869 10.2966 12 10.2966C12.2131 10.2966 12.4239 10.3415 12.6185 10.4282C12.8132 10.5149 12.9875 10.6416 13.13 10.8L16 13.8599" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M3 7.41992L3 17.4199C3 19.6291 4.79086 21.4199 7 21.4199H17C19.2091 21.4199 21 19.6291 21 17.4199V7.41992C21 5.21078 19.2091 3.41992 17 3.41992H7C4.79086 3.41992 3 5.21078 3 7.41992Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<svg
|
||||
width="2em"
|
||||
height="2em"
|
||||
viewBox="-0.5 0 25 25"
|
||||
fill="none"
|
||||
stroke="rgb(173, 181, 189)"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
role="button"
|
||||
@onclick="MoveDown"
|
||||
>
|
||||
<path d="M16 10.99L13.1299 14.05C12.9858 14.2058 12.811 14.3298 12.6166 14.4148C12.4221 14.4998 12.2122 14.5437 12 14.5437C11.7878 14.5437 11.5779 14.4998 11.3834 14.4148C11.189 14.3298 11.0142 14.2058 10.87 14.05L8 10.99" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M21 17.4199V7.41992C21 5.21078 19.2091 3.41992 17 3.41992L7 3.41992C4.79086 3.41992 3 5.21078 3 7.41992V17.4199C3 19.6291 4.79086 21.4199 7 21.4199H17C19.2091 21.4199 21 19.6291 21 17.4199Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@@ -79,7 +79,7 @@
|
||||
<Footer>
|
||||
@if(doingAsyncThings)
|
||||
{
|
||||
<Spinnner />
|
||||
<Spinner />
|
||||
}
|
||||
</Footer>
|
||||
</Modal>
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
private string htmlLabel => Label.Replace("-", "");
|
||||
|
||||
private string selectedItemId { get; set; }
|
||||
|
||||
private void onSelect(ChangeEventArgs e)
|
||||
{
|
||||
var newId = e.Value?.ToString();
|
||||
@@ -33,7 +31,6 @@
|
||||
<select
|
||||
id="@htmlLabel"
|
||||
name="@htmlLabel"
|
||||
@bind="selectedItemId"
|
||||
@oninput="onSelect"
|
||||
>
|
||||
@foreach(var option in Options)
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired]
|
||||
public string Value { get; set; }
|
||||
public string Value { get; set; } = default!;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Action<string> OnChange { get; set; }
|
||||
public Action<string> OnChange { get; set; } = default!;
|
||||
|
||||
private string randomId = "monaco-editor-" + BitConverter.ToString(new byte[16].Select(b => (byte)new Random().Next(256)).ToArray()).Replace("-", "");
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@code {
|
||||
private Modal? modal { get; set; }
|
||||
|
||||
private LocalQuiz testQuiz;
|
||||
private LocalQuiz? testQuiz;
|
||||
|
||||
private string? error { get; set; } = null;
|
||||
private string _quizMarkdownInput { get; set; } = "";
|
||||
@@ -68,7 +68,10 @@
|
||||
{
|
||||
<p class="text-danger text-truncate">Error: @error</p>
|
||||
}
|
||||
<QuizPreview Quiz="testQuiz" />
|
||||
@if(testQuiz != null)
|
||||
{
|
||||
<QuizPreview Quiz="testQuiz" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user