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:
@@ -15,7 +15,7 @@
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string CourseName { get; set; }
|
||||
public string? CourseName { get; set; }
|
||||
|
||||
private bool loading = true;
|
||||
|
||||
@@ -54,11 +54,6 @@
|
||||
Select New Course
|
||||
</button>
|
||||
<CourseSettings />
|
||||
<AssignmentTemplateManagement />
|
||||
|
||||
@* <button class="btn btn-outline-primary" @onclick="planner.SyncWithCanvas">
|
||||
Sync With Canvas
|
||||
</button> *@
|
||||
<a class="btn btn-outline-secondary" target="_blank"
|
||||
href="@($"{Environment.GetEnvironmentVariable("CANVAS_URL")}/courses/{planner.LocalCourse.Settings.CanvasId}")">
|
||||
View In Canvas
|
||||
|
||||
@@ -86,7 +86,7 @@ app.MapFallbackToPage("/_Host");
|
||||
|
||||
app.Start();
|
||||
|
||||
var addresses = app.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses;
|
||||
var addresses = app.Services.GetService<IServer>()?.Features.Get<IServerAddressesFeature>()?.Addresses ?? [];
|
||||
|
||||
foreach (var address in addresses)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
<div class="row border-bottom">
|
||||
@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>
|
||||
@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 class="text-end">
|
||||
<div>
|
||||
Required Points: @requiredPoints
|
||||
</div>
|
||||
<div>
|
||||
Extra Credit Points @extraCreditPoints
|
||||
</div>
|
||||
</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>
|
||||
}
|
||||
@if(testQuiz != null)
|
||||
{
|
||||
<QuizPreview Quiz="testQuiz" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
loadingTerms = true;
|
||||
terms = await canvas.GetCurrentTermsFor();
|
||||
loadingTerms = false;
|
||||
directoriesNotUsed = await fileStorageManager.GetEmptyDirectories();
|
||||
directoriesNotUsed = fileStorageManager.GetEmptyDirectories();
|
||||
}
|
||||
|
||||
private async Task SaveNewCourse()
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
@using CanvasModel.Assignments;
|
||||
|
||||
@inject DragContainer dragContainer
|
||||
@inject CoursePlanner planner
|
||||
@inject NavigationManager Navigation
|
||||
@inject AssignmentEditorContext assignmentContext
|
||||
|
||||
@@ -13,8 +12,6 @@
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule Module { get; set; } = new();
|
||||
private bool showUpdateForm = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
planner.StateHasChanged += reload;
|
||||
@@ -78,8 +75,9 @@
|
||||
&& planner.LocalCourse.Settings.CanvasId != null
|
||||
&& planner.CanvasAssignments != null
|
||||
&& planner.CanvasModules != null
|
||||
&& assignmentInCanvas != null
|
||||
&& Assignment.NeedsUpdates(
|
||||
assignmentInCanvas,
|
||||
(CanvasAssignment)assignmentInCanvas,
|
||||
Assignment.GetCanvasAssignmentGroupId(planner.LocalCourse.Settings.AssignmentGroups)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -73,12 +73,15 @@
|
||||
</form>
|
||||
<br>
|
||||
<label class="form-label">Assignment Group</label>
|
||||
@if(planner != null)
|
||||
{
|
||||
<ButtonSelect
|
||||
Label="Assignment Group"
|
||||
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
||||
Options="planner.LocalCourse?.Settings.AssignmentGroups ?? []"
|
||||
GetName="(g) => g?.Name"
|
||||
OnSelect="(g) => setAssignmentGroup(g)"
|
||||
/>
|
||||
}
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
|
||||
@@ -71,12 +71,15 @@
|
||||
</form>
|
||||
<br>
|
||||
<label class="form-label">Assignment Group</label>
|
||||
@if(planner != null && planner.LocalCourse != null)
|
||||
{
|
||||
<ButtonSelect
|
||||
Label="Assignment Group"
|
||||
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
||||
GetName="(g) => g?.Name"
|
||||
OnSelect="(g) => setAssignmentGroup(g)"
|
||||
/>
|
||||
}
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
@inject DragContainer dragContainer
|
||||
@inject QuizEditorContext quizContext
|
||||
@inject CoursePlanner planner
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@inherits DroppableQuiz
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
@using Management.Web.Shared.Module.Assignment
|
||||
|
||||
@inject DragContainer dragContainer
|
||||
@inject CoursePlanner planner
|
||||
@inject NavigationManager Navigation
|
||||
@inject AssignmentEditorContext assignmentContext
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@using Management.Web.Shared.Components.Quiz
|
||||
@inject DragContainer dragContainer
|
||||
@inject CoursePlanner planner
|
||||
@inject QuizEditorContext quizContext
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AssignmentEditorContext
|
||||
|
||||
public void SaveAssignment(LocalAssignment newAssignment)
|
||||
{
|
||||
if (planner.LocalCourse != null)
|
||||
if (planner.LocalCourse != null && Assignment != null)
|
||||
{
|
||||
// run discovery on Assignment, it was the last stored version of the assignment
|
||||
var currentModule = getCurrentLocalModule(Assignment, planner.LocalCourse);
|
||||
@@ -106,7 +106,6 @@ public class AssignmentEditorContext
|
||||
courseId: (ulong)planner.LocalCourse.Settings.CanvasId,
|
||||
canvasAssignmentId: canvasAssignmentId,
|
||||
localAssignment: Assignment,
|
||||
htmlDescription: Assignment.GetDescriptionHtml(),
|
||||
canvasAssignmentGroupId: (ulong)canvasAssignmentGroupId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class QuizEditorContext
|
||||
get => _quiz;
|
||||
set
|
||||
{
|
||||
if (_quiz == null && value != null)
|
||||
if (_quiz == null && value != null && planner != null && planner.LocalCourse != null)
|
||||
{
|
||||
_module = getCurrentLocalModule(value, planner.LocalCourse);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
var canvasAssignment = canvasAssignments.FirstOrDefault(
|
||||
ca => ca.Name == localAssignment.Name
|
||||
);
|
||||
string localHtmlDescription = localAssignment.GetDescriptionHtml();
|
||||
|
||||
var canvasAssignmentGroupId = localAssignment.GetCanvasAssignmentGroupId(localCourse.Settings.AssignmentGroups);
|
||||
|
||||
@@ -35,10 +34,9 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
localAssignment,
|
||||
canvasAssignment,
|
||||
canvas,
|
||||
localHtmlDescription,
|
||||
canvasAssignmentGroupId
|
||||
)
|
||||
: await canvas.Assignments.Create(canvasCourseId, localAssignment, localHtmlDescription, canvasAssignmentGroupId);
|
||||
: await canvas.Assignments.Create(canvasCourseId, localAssignment, canvasAssignmentGroupId);
|
||||
}
|
||||
|
||||
private static async Task<ulong> updateAssignmentIfNeeded(
|
||||
@@ -47,7 +45,6 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
LocalAssignment localAssignment,
|
||||
CanvasAssignment canvasAssignment,
|
||||
CanvasService canvas,
|
||||
string localHtmlDescription,
|
||||
ulong? canvasAssignmentGroupId
|
||||
)
|
||||
{
|
||||
@@ -63,8 +60,7 @@ public static partial class AssignmentSyncronizationExtensions
|
||||
courseId: canvasCourseId,
|
||||
canvasAssignmentId: canvasAssignment.Id,
|
||||
localAssignment,
|
||||
localHtmlDescription,
|
||||
(ulong)canvasAssignmentGroupId
|
||||
canvasAssignmentGroupId
|
||||
);
|
||||
}
|
||||
return canvasAssignment.Id;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace LocalModels;
|
||||
public record LocalCourse
|
||||
{
|
||||
public IEnumerable<LocalModule> Modules { get; init; } = Enumerable.Empty<LocalModule>();
|
||||
public LocalCourseSettings Settings { get; set; }
|
||||
public required LocalCourseSettings Settings { get; set; }
|
||||
}
|
||||
|
||||
public record SimpleTimeOnly
|
||||
|
||||
@@ -38,7 +38,6 @@ public class CanvasAssignmentService
|
||||
public async Task<ulong> Create(
|
||||
ulong canvasCourseId,
|
||||
LocalAssignment localAssignment,
|
||||
string htmlDescription,
|
||||
ulong? canvasAssignmentGroupId
|
||||
)
|
||||
{
|
||||
@@ -49,7 +48,7 @@ public class CanvasAssignmentService
|
||||
{
|
||||
name = localAssignment.Name,
|
||||
submission_types = localAssignment.SubmissionTypes.Select(t => t.ToString()),
|
||||
description = htmlDescription,
|
||||
description = localAssignment.GetDescriptionHtml(),
|
||||
due_at = localAssignment.DueAt,
|
||||
lock_at = localAssignment.LockAt,
|
||||
points_possible = localAssignment.PointsPossible,
|
||||
@@ -71,8 +70,7 @@ public class CanvasAssignmentService
|
||||
ulong courseId,
|
||||
ulong canvasAssignmentId,
|
||||
LocalAssignment localAssignment,
|
||||
string htmlDescription,
|
||||
ulong canvasAssignmentGroupId
|
||||
ulong? canvasAssignmentGroupId
|
||||
)
|
||||
{
|
||||
log.Log($"updating assignment: {localAssignment.Name}");
|
||||
|
||||
@@ -64,8 +64,8 @@ public class CanvasService
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
logger.Error(response.Content);
|
||||
logger.Error(response.ResponseUri?.ToString());
|
||||
logger.Error(response?.Content ?? "");
|
||||
logger.Error(response?.ResponseUri?.ToString() ?? "");
|
||||
throw new Exception("error getting course from canvas");
|
||||
}
|
||||
return data;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FileStorageManager
|
||||
this.logger.Log("Using storage directory: " + _basePath);
|
||||
|
||||
}
|
||||
public async Task SaveCourseAsync(LocalCourse course, LocalCourse previouslyStoredCourse)
|
||||
public async Task SaveCourseAsync(LocalCourse course, LocalCourse? previouslyStoredCourse)
|
||||
{
|
||||
await _saveMarkdownCourse.Save(course, previouslyStoredCourse);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class FileStorageManager
|
||||
return await _courseMarkdownLoader.LoadSavedMarkdownCourses();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> GetEmptyDirectories()
|
||||
public IEnumerable<string> GetEmptyDirectories()
|
||||
{
|
||||
if(!Directory.Exists(_basePath))
|
||||
throw new DirectoryNotFoundException($"Cannot get empty directories, {_basePath} does not exist");
|
||||
|
||||
@@ -13,7 +13,7 @@ public class MarkdownCourseSaver
|
||||
_basePath = FileConfiguration.GetBasePath();
|
||||
}
|
||||
|
||||
public async Task Save(LocalCourse course, LocalCourse previouslyStoredCourse)
|
||||
public async Task Save(LocalCourse course, LocalCourse? previouslyStoredCourse)
|
||||
{
|
||||
var courseDirectory = $"{_basePath}/{course.Settings.Name}";
|
||||
if (!Directory.Exists(courseDirectory))
|
||||
|
||||
Reference in New Issue
Block a user