mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
fixed assignment save bug
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public LocalModule Module { get; set; } = default!;
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[EditorRequired]
|
[EditorRequired]
|
||||||
@@ -54,6 +53,7 @@
|
|||||||
.Select(s => s.Points)
|
.Select(s => s.Points)
|
||||||
.Sum();
|
.Sum();
|
||||||
|
|
||||||
|
|
||||||
var newAssignment = Assignment with
|
var newAssignment = Assignment with
|
||||||
{
|
{
|
||||||
Name=name,
|
Name=name,
|
||||||
@@ -69,20 +69,29 @@
|
|||||||
|
|
||||||
if(planner.LocalCourse != null)
|
if(planner.LocalCourse != null)
|
||||||
{
|
{
|
||||||
|
var currentModule = planner
|
||||||
|
.LocalCourse
|
||||||
|
.Modules
|
||||||
|
.First(m =>
|
||||||
|
m.Assignments
|
||||||
|
.Select(a => a.Id)
|
||||||
|
.Contains(Assignment.Id)
|
||||||
|
) ?? throw new Exception("could not find current module in assignment form");
|
||||||
|
var updatedModules = planner.LocalCourse.Modules.Select(m =>
|
||||||
|
m.Name == currentModule.Name
|
||||||
|
? currentModule with
|
||||||
|
{
|
||||||
|
Assignments=currentModule.Assignments.Select(a =>
|
||||||
|
a.Id == newAssignment.Id
|
||||||
|
? newAssignment
|
||||||
|
: a
|
||||||
|
).ToArray()
|
||||||
|
}
|
||||||
|
: m
|
||||||
|
).ToArray();
|
||||||
planner.LocalCourse = planner.LocalCourse with
|
planner.LocalCourse = planner.LocalCourse with
|
||||||
{
|
{
|
||||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
Modules=updatedModules
|
||||||
m.Name != Module.Name
|
|
||||||
? m
|
|
||||||
: Module with
|
|
||||||
{
|
|
||||||
Assignments=Module.Assignments.Select(a =>
|
|
||||||
a.Id == newAssignment.Id
|
|
||||||
? newAssignment
|
|
||||||
: a
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
AssignmentModal?.Hide();
|
AssignmentModal?.Hide();
|
||||||
|
|||||||
@@ -96,6 +96,9 @@
|
|||||||
<h5>Assignments</h5>
|
<h5>Assignments</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
|
<NewQuiz
|
||||||
|
Module="Module"
|
||||||
|
/>
|
||||||
<NewAssignment
|
<NewAssignment
|
||||||
Module="Module"
|
Module="Module"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -33,16 +33,17 @@
|
|||||||
|
|
||||||
if(planner.LocalCourse != null)
|
if(planner.LocalCourse != null)
|
||||||
{
|
{
|
||||||
|
var newModules =planner.LocalCourse.Modules.Select(m =>
|
||||||
|
m.Name != Module.Name
|
||||||
|
? m
|
||||||
|
: Module with
|
||||||
|
{
|
||||||
|
Assignments=Module.Assignments.Append(newAssignment)
|
||||||
|
}
|
||||||
|
);
|
||||||
planner.LocalCourse = planner.LocalCourse with
|
planner.LocalCourse = planner.LocalCourse with
|
||||||
{
|
{
|
||||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
Modules=newModules
|
||||||
m.Name != Module.Name
|
|
||||||
? m
|
|
||||||
: Module with
|
|
||||||
{
|
|
||||||
Assignments=Module.Assignments.Append(newAssignment)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
modal?.Hide();
|
modal?.Hide();
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
class="btn btn-outline-secondary"
|
class="btn btn-outline-secondary"
|
||||||
@onclick="() => modal?.Show()"
|
@onclick="() => modal?.Show()"
|
||||||
>
|
>
|
||||||
New Assignment
|
+ Assignment
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<Modal @ref="modal">
|
<Modal @ref="modal">
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
@onclick="submitHandler"
|
@onclick="submitHandler"
|
||||||
>
|
>
|
||||||
Save changes
|
Create Assignment
|
||||||
</button>
|
</button>
|
||||||
</Footer>
|
</Footer>
|
||||||
</Modal>
|
</Modal>
|
||||||
66
Management.Web/Shared/Module/NewQuiz.razor
Normal file
66
Management.Web/Shared/Module/NewQuiz.razor
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
@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; } = null;
|
||||||
|
|
||||||
|
private void submitHandler()
|
||||||
|
{
|
||||||
|
Console.WriteLine("new quiz");
|
||||||
|
var newQuiz = new LocalQuiz
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name=Name,
|
||||||
|
};
|
||||||
|
if(planner.LocalCourse != null)
|
||||||
|
{
|
||||||
|
var newModules = planner.LocalCourse.Modules.Select(m =>
|
||||||
|
m.Name != Module.Name
|
||||||
|
? m
|
||||||
|
: Module with
|
||||||
|
{
|
||||||
|
Quizzes=Module.Quizzes.Append(newQuiz)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
planner.LocalCourse = planner.LocalCourse with
|
||||||
|
{
|
||||||
|
Modules=newModules
|
||||||
|
};
|
||||||
|
}
|
||||||
|
modal?.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="btn btn-outline-secondary"
|
||||||
|
@onclick="() => modal?.Show()"
|
||||||
|
>
|
||||||
|
+ Quiz
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Modal @ref="modal">
|
||||||
|
<Title>New Quiz</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
|
||||||
|
class="btn btn-primary"
|
||||||
|
@onclick="submitHandler"
|
||||||
|
>
|
||||||
|
CreateQuiz
|
||||||
|
</button>
|
||||||
|
</Footer>
|
||||||
|
</Modal>
|
||||||
@@ -112,6 +112,8 @@ public static partial class CoursePlannerSyncronizationExtensions
|
|||||||
var canvasHtmlDescription = canvasAssignment.Description;
|
var canvasHtmlDescription = canvasAssignment.Description;
|
||||||
canvasHtmlDescription = CanvasScriptTagRegex().Replace(canvasHtmlDescription, "");
|
canvasHtmlDescription = CanvasScriptTagRegex().Replace(canvasHtmlDescription, "");
|
||||||
canvasHtmlDescription = CanvasLinkTagRegex().Replace(canvasHtmlDescription, "");
|
canvasHtmlDescription = CanvasLinkTagRegex().Replace(canvasHtmlDescription, "");
|
||||||
|
canvasHtmlDescription = canvasHtmlDescription.Replace(">", ">");
|
||||||
|
canvasHtmlDescription = canvasHtmlDescription.Replace("<", "<");
|
||||||
|
|
||||||
var dueDatesSame = canvasAssignment.DueAt == localAssignment.DueAt;
|
var dueDatesSame = canvasAssignment.DueAt == localAssignment.DueAt;
|
||||||
var descriptionSame = canvasHtmlDescription == localHtmlDescription;
|
var descriptionSame = canvasHtmlDescription == localHtmlDescription;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using LocalModels;
|
namespace LocalModels;
|
||||||
|
|
||||||
public record RubricItem
|
public record RubricItem
|
||||||
{
|
{
|
||||||
@@ -46,11 +46,11 @@ public record LocalAssignment
|
|||||||
public Dictionary<string, string> TemplateVariables { get; init; } =
|
public Dictionary<string, string> TemplateVariables { get; init; } =
|
||||||
new Dictionary<string, string>();
|
new Dictionary<string, string>();
|
||||||
public bool LockAtDueDate { get; init; }
|
public bool LockAtDueDate { get; init; }
|
||||||
public IEnumerable<RubricItem> Rubric { get; init; } = new RubricItem[] { };
|
public IEnumerable<RubricItem> Rubric { get; init; } = Array.Empty<RubricItem>();
|
||||||
public DateTime? LockAt { get; init; }
|
public DateTime? LockAt { get; init; }
|
||||||
public DateTime DueAt { get; init; }
|
public DateTime DueAt { get; init; }
|
||||||
public int PointsPossible { get; init; }
|
public int PointsPossible { get; init; }
|
||||||
public IEnumerable<string> SubmissionTypes { get; init; } = new string[] { };
|
public IEnumerable<string> SubmissionTypes { get; init; } = Array.Empty<string>();
|
||||||
|
|
||||||
public string GetRubricHtml()
|
public string GetRubricHtml()
|
||||||
{
|
{
|
||||||
@@ -73,9 +73,9 @@ public record LocalAssignment
|
|||||||
|
|
||||||
if (UseTemplate)
|
if (UseTemplate)
|
||||||
{
|
{
|
||||||
var template = templates?.FirstOrDefault(t => t.Id == TemplateId);
|
var template =
|
||||||
if (template == null)
|
(templates?.FirstOrDefault(t => t.Id == TemplateId))
|
||||||
throw new Exception($"Could not find template with id {TemplateId}");
|
?? throw new Exception($"Could not find template with id {TemplateId}");
|
||||||
|
|
||||||
var html = Markdig.Markdown.ToHtml(template.Markdown);
|
var html = Markdig.Markdown.ToHtml(template.Markdown);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CanvasModel.Assignments;
|
using CanvasModel.Assignments;
|
||||||
|
using LocalModels;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
|
||||||
namespace Management.Services.Canvas;
|
namespace Management.Services.Canvas;
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -16,26 +16,3 @@ Development command: `dotnet watch --project Management.Web/`
|
|||||||
Apparently the VSCode razor extension was compiled with a preview of dotnet 6... and only uses openssl 1.1. After installing openssl1.1 you can tell vscode to provide it with `export CLR_OPENSSL_VERSION_OVERRIDE=1.1; code ~/projects/canvasManagement`.
|
Apparently the VSCode razor extension was compiled with a preview of dotnet 6... and only uses openssl 1.1. After installing openssl1.1 you can tell vscode to provide it with `export CLR_OPENSSL_VERSION_OVERRIDE=1.1; code ~/projects/canvasManagement`.
|
||||||
|
|
||||||
The issue can be tracked [here](https://github.com/dotnet/razor/issues/6241)
|
The issue can be tracked [here](https://github.com/dotnet/razor/issues/6241)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Daily Reading</h1>
|
|
||||||
<p>Read today's assignment and do well please.</p>
|
|
||||||
<p><a href="https://alexmickelson.guru">Github Submit URL</a></p>
|
|
||||||
<hr><h1>Rubric</h1><pre><code class="language-json">[
|
|
||||||
{"label": "More Reading", "points": 5},
|
|
||||||
{"label": "sum to 8", "points": 1},
|
|
||||||
{"label": "(Extra Credit) Rubric Things", "points": 2}
|
|
||||||
]</code></pre>
|
|
||||||
|
|
||||||
<h1>Daily Reading</h1>
|
|
||||||
<p>Read today's assignment and do well please.</p>
|
|
||||||
<p><a href="https://alexmickelson.guru">Github Submit URL</a></p>
|
|
||||||
<hr /><h1>Rubric</h1><pre><code class="language-json">[
|
|
||||||
{"label": "More Reading", "points": 5},
|
|
||||||
{"label": "sum to 8", "points": 1},
|
|
||||||
{"label": "(Extra Credit) Rubric Things", "points": 2}
|
|
||||||
]</code></pre>
|
|
||||||
Reference in New Issue
Block a user