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
|
||||
|
||||
@code {
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
@@ -54,6 +53,7 @@
|
||||
.Select(s => s.Points)
|
||||
.Sum();
|
||||
|
||||
|
||||
var newAssignment = Assignment with
|
||||
{
|
||||
Name=name,
|
||||
@@ -69,20 +69,29 @@
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
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
|
||||
{
|
||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Select(a =>
|
||||
Assignments=currentModule.Assignments.Select(a =>
|
||||
a.Id == newAssignment.Id
|
||||
? newAssignment
|
||||
: a
|
||||
)
|
||||
).ToArray()
|
||||
}
|
||||
)
|
||||
: m
|
||||
).ToArray();
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=updatedModules
|
||||
};
|
||||
}
|
||||
AssignmentModal?.Hide();
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<h5>Assignments</h5>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<NewQuiz
|
||||
Module="Module"
|
||||
/>
|
||||
<NewAssignment
|
||||
Module="Module"
|
||||
/>
|
||||
|
||||
@@ -33,16 +33,17 @@
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=planner.LocalCourse.Modules.Select(m =>
|
||||
var newModules =planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Append(newAssignment)
|
||||
}
|
||||
)
|
||||
);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=newModules
|
||||
};
|
||||
}
|
||||
modal?.Hide();
|
||||
@@ -52,7 +53,7 @@
|
||||
class="btn btn-outline-secondary"
|
||||
@onclick="() => modal?.Show()"
|
||||
>
|
||||
New Assignment
|
||||
+ Assignment
|
||||
</button>
|
||||
|
||||
<Modal @ref="modal">
|
||||
@@ -69,7 +70,7 @@
|
||||
class="btn btn-primary"
|
||||
@onclick="submitHandler"
|
||||
>
|
||||
Save changes
|
||||
Create Assignment
|
||||
</button>
|
||||
</Footer>
|
||||
</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;
|
||||
canvasHtmlDescription = CanvasScriptTagRegex().Replace(canvasHtmlDescription, "");
|
||||
canvasHtmlDescription = CanvasLinkTagRegex().Replace(canvasHtmlDescription, "");
|
||||
canvasHtmlDescription = canvasHtmlDescription.Replace(">", ">");
|
||||
canvasHtmlDescription = canvasHtmlDescription.Replace("<", "<");
|
||||
|
||||
var dueDatesSame = canvasAssignment.DueAt == localAssignment.DueAt;
|
||||
var descriptionSame = canvasHtmlDescription == localHtmlDescription;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using LocalModels;
|
||||
namespace LocalModels;
|
||||
|
||||
public record RubricItem
|
||||
{
|
||||
@@ -46,11 +46,11 @@ public record LocalAssignment
|
||||
public Dictionary<string, string> TemplateVariables { get; init; } =
|
||||
new Dictionary<string, string>();
|
||||
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 DueAt { 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()
|
||||
{
|
||||
@@ -73,9 +73,9 @@ public record LocalAssignment
|
||||
|
||||
if (UseTemplate)
|
||||
{
|
||||
var template = templates?.FirstOrDefault(t => t.Id == TemplateId);
|
||||
if (template == null)
|
||||
throw new Exception($"Could not find template with id {TemplateId}");
|
||||
var template =
|
||||
(templates?.FirstOrDefault(t => t.Id == TemplateId))
|
||||
?? throw new Exception($"Could not find template with id {TemplateId}");
|
||||
|
||||
var html = Markdig.Markdown.ToHtml(template.Markdown);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CanvasModel.Assignments;
|
||||
using LocalModels;
|
||||
using RestSharp;
|
||||
|
||||
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`.
|
||||
|
||||
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