mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
added quiz popup form and displaying on month
This commit is contained in:
@@ -40,6 +40,7 @@ builder.Services.AddScoped<CanvasService, CanvasService>();
|
|||||||
builder.Services.AddScoped<YamlManager>();
|
builder.Services.AddScoped<YamlManager>();
|
||||||
builder.Services.AddScoped<CoursePlanner>();
|
builder.Services.AddScoped<CoursePlanner>();
|
||||||
builder.Services.AddScoped<AssignmentEditorContext>();
|
builder.Services.AddScoped<AssignmentEditorContext>();
|
||||||
|
builder.Services.AddScoped<QuizEditorContext>();
|
||||||
builder.Services.AddScoped<DragContainer>();
|
builder.Services.AddScoped<DragContainer>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
if (assignmentContext.Assignment != null)
|
if (assignmentContext.Assignment != null)
|
||||||
{
|
{
|
||||||
Description = assignmentContext.Assignment.Description;
|
Description = assignmentContext.Assignment.Description;
|
||||||
Console.WriteLine("loaded description");
|
|
||||||
Console.WriteLine(Description);
|
|
||||||
Preview = Markdown.ToHtml(Description);
|
Preview = Markdown.ToHtml(Description);
|
||||||
TemplateId = assignmentContext.Assignment.TemplateId;
|
TemplateId = assignmentContext.Assignment.TemplateId;
|
||||||
UseTemplate = TemplateId != null && TemplateId != "";
|
UseTemplate = TemplateId != null && TemplateId != "";
|
||||||
|
|||||||
@@ -118,7 +118,6 @@
|
|||||||
<Body>
|
<Body>
|
||||||
@if (assignmentContext.Assignment != null)
|
@if (assignmentContext.Assignment != null)
|
||||||
{
|
{
|
||||||
<form @onsubmit:preventDefault="true">
|
|
||||||
<div class="m-1">
|
<div class="m-1">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
Name
|
Name
|
||||||
@@ -150,7 +149,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<RubricEditor />
|
<RubricEditor />
|
||||||
<SubmissionTypeSelector />
|
<SubmissionTypeSelector />
|
||||||
</form>
|
|
||||||
}
|
}
|
||||||
</Body>
|
</Body>
|
||||||
<Footer>
|
<Footer>
|
||||||
|
|||||||
@@ -1,42 +1,41 @@
|
|||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
@inject QuizEditorContext quizContext
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public LocalModule Module { get; set; } = default!;
|
private Modal? modal { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
protected override void OnInitialized()
|
||||||
[EditorRequired]
|
|
||||||
public LocalQuiz Quiz
|
|
||||||
{
|
{
|
||||||
get;
|
quizContext.StateHasChanged += reload;
|
||||||
set;
|
}
|
||||||
} = default!;
|
private void reload()
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
[EditorRequired]
|
|
||||||
public bool Show { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public Action OnHide { get; set; } = () => { };
|
|
||||||
private Modal? Modal { get; set; }
|
|
||||||
|
|
||||||
private void submitHandler ()
|
|
||||||
{
|
{
|
||||||
|
if (quizContext.Quiz != null)
|
||||||
|
{
|
||||||
|
//initialize
|
||||||
|
modal?.Show();
|
||||||
|
this.InvokeAsync(this.StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
quizContext.StateHasChanged -= reload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<Modal @ref="Modal" OnHide="@(() => OnHide())">
|
<Modal @ref="modal" OnHide="() => quizContext.Quiz = null" >
|
||||||
<Title>
|
<Title>
|
||||||
@Quiz.Name
|
@quizContext.Quiz?.Name
|
||||||
</Title>
|
</Title>
|
||||||
<Body>
|
<Body>
|
||||||
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</Body>
|
</Body>
|
||||||
<Footer>
|
<Footer>
|
||||||
<button class="btn btn-primary" @onclick="submitHandler">
|
<button
|
||||||
Save
|
class="btn btn-primary"
|
||||||
|
@onclick="() => modal?.Hide()"
|
||||||
|
>
|
||||||
|
Done
|
||||||
</button>
|
</button>
|
||||||
</Footer>
|
</Footer>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
@using Management.Web.Shared.Module
|
@using Management.Web.Shared.Module
|
||||||
@using Management.Web.Shared.Semester
|
@using Management.Web.Shared.Semester
|
||||||
@using Management.Web.Shared.Components.AssignmentForm
|
@using Management.Web.Shared.Components.AssignmentForm
|
||||||
|
@using Management.Web.Shared.Components.Quiz
|
||||||
|
|
||||||
@inject CanvasService canvas
|
@inject CanvasService canvas
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<AssignmentForm />
|
<AssignmentForm />
|
||||||
|
<QuizForm />
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col overflow-y-auto border rounded " style="max-height: 95vh;">
|
<div class="col overflow-y-auto border rounded " style="max-height: 95vh;">
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
@using Management.Web.Shared.Components.Quiz
|
@using Management.Web.Shared.Components.Quiz
|
||||||
|
|
||||||
@inject DragContainer dragContainer
|
@inject DragContainer dragContainer
|
||||||
|
@inject QuizEditorContext quizContext
|
||||||
|
|
||||||
@inherits DroppableQuiz
|
@inherits DroppableQuiz
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
private bool showUpdateForm { get; set; } = false;
|
|
||||||
|
|
||||||
|
|
||||||
private void HandleDragStart()
|
private void HandleDragStart()
|
||||||
{
|
{
|
||||||
dragContainer.DropCallback = dropCallback;
|
dragContainer.DropCallback = dropCallback;
|
||||||
@@ -26,7 +24,7 @@
|
|||||||
draggable="true"
|
draggable="true"
|
||||||
@ondragstart="HandleDragStart"
|
@ondragstart="HandleDragStart"
|
||||||
@ondragend="HandleDragEnd"
|
@ondragend="HandleDragEnd"
|
||||||
@onclick="@(() => showUpdateForm = true)"
|
@onclick="@(() => quizContext.Quiz = Quiz)"
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
@using Management.Web.Shared.Components.AssignmentForm
|
|
||||||
|
|
||||||
@inject DragContainer dragContainer
|
@inject DragContainer dragContainer
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IEnumerable<LocalAssignment> TodaysAssignments {
|
private IEnumerable<LocalAssignment> TodaysAssignments
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(planner.LocalCourse == null || date == null)
|
if(planner.LocalCourse == null || date == null)
|
||||||
@@ -38,6 +39,19 @@
|
|||||||
.Where(a => a.DueAt.Date == date?.Date);
|
.Where(a => a.DueAt.Date == date?.Date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<LocalQuiz> todaysQuizzes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(planner.LocalCourse == null || date == null)
|
||||||
|
return Enumerable.Empty<LocalQuiz>();
|
||||||
|
else
|
||||||
|
return planner.LocalCourse.Modules
|
||||||
|
.SelectMany(m => m.Quizzes)
|
||||||
|
.Where(q => q.DueAt.Date == date?.Date);
|
||||||
|
}
|
||||||
|
}
|
||||||
private string calculatedClass
|
private string calculatedClass
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -78,7 +92,6 @@
|
|||||||
|
|
||||||
void OnDrop()
|
void OnDrop()
|
||||||
{
|
{
|
||||||
@* System.Console.WriteLine("on drop"); *@
|
|
||||||
dragging = false;
|
dragging = false;
|
||||||
if(dragContainer.DropCallback == null){
|
if(dragContainer.DropCallback == null){
|
||||||
System.Console.WriteLine("no drop callback set");
|
System.Console.WriteLine("no drop callback set");
|
||||||
@@ -105,5 +118,10 @@
|
|||||||
{
|
{
|
||||||
<AssignmentInDay Assignment="assignment" @key="@assignment" />
|
<AssignmentInDay Assignment="assignment" @key="@assignment" />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@foreach(var quiz in todaysQuizzes)
|
||||||
|
{
|
||||||
|
<QuizInDay Quiz="quiz" @key="@quiz" />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
29
Management.Web/Shared/Semester/Day/QuizInDay.razor
Normal file
29
Management.Web/Shared/Semester/Day/QuizInDay.razor
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
@using Management.Web.Shared.Components.Quiz
|
||||||
|
@inject DragContainer dragContainer
|
||||||
|
@inject CoursePlanner planner
|
||||||
|
@inject QuizEditorContext quizContext
|
||||||
|
|
||||||
|
@inherits DroppableQuiz
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
private void HandleDragStart()
|
||||||
|
{
|
||||||
|
dragContainer.DropCallback = dropCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleDragEnd()
|
||||||
|
{
|
||||||
|
dragContainer.DropCallback = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<div
|
||||||
|
draggable="true"
|
||||||
|
@ondragstart="HandleDragStart"
|
||||||
|
@ondragend="HandleDragEnd"
|
||||||
|
@onclick="@(() => quizContext.Quiz = Quiz)"
|
||||||
|
role="button"
|
||||||
|
>
|
||||||
|
@Quiz.Name
|
||||||
|
</div>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
@using System.Linq
|
@using System.Linq
|
||||||
|
@using Management.Web.Shared.Semester.Day
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ public class AssignmentEditorContext
|
|||||||
private LocalAssignment? _assignment;
|
private LocalAssignment? _assignment;
|
||||||
public LocalAssignment? Assignment
|
public LocalAssignment? Assignment
|
||||||
{
|
{
|
||||||
get =>_assignment;
|
get => _assignment;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_assignment = value;
|
_assignment = value;
|
||||||
StateHasChanged?.Invoke();
|
StateHasChanged?.Invoke();
|
||||||
Console.WriteLine("new assignment");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ public class AssignmentEditorContext
|
|||||||
var currentModule =
|
var currentModule =
|
||||||
planner.LocalCourse.Modules.First(
|
planner.LocalCourse.Modules.First(
|
||||||
m => m.Assignments.Select(a => a.Id).Contains(newAssignment.Id)
|
m => m.Assignments.Select(a => a.Id).Contains(newAssignment.Id)
|
||||||
) ?? throw new Exception("could not find current module in assignment description form");
|
) ?? throw new Exception("could not find current module in assignment editor context");
|
||||||
|
|
||||||
var updatedModules = planner.LocalCourse.Modules
|
var updatedModules = planner.LocalCourse.Modules
|
||||||
.Select(
|
.Select(
|
||||||
|
|||||||
50
Management/Features/Configuration/QuizEditorContext.cs
Normal file
50
Management/Features/Configuration/QuizEditorContext.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using LocalModels;
|
||||||
|
using Management.Planner;
|
||||||
|
|
||||||
|
public class QuizEditorContext
|
||||||
|
{
|
||||||
|
public event Action? StateHasChanged;
|
||||||
|
private CoursePlanner planner { get; }
|
||||||
|
|
||||||
|
public QuizEditorContext(CoursePlanner planner)
|
||||||
|
{
|
||||||
|
this.planner = planner;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalQuiz? _quiz;
|
||||||
|
public LocalQuiz? Quiz
|
||||||
|
{
|
||||||
|
get => _quiz;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_quiz = value;
|
||||||
|
StateHasChanged?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveQuiz(LocalQuiz newQuiz)
|
||||||
|
{
|
||||||
|
if (planner.LocalCourse != null)
|
||||||
|
{
|
||||||
|
var currentModule =
|
||||||
|
planner.LocalCourse.Modules.First(m => m.Quizzes.Select(q => q.Id).Contains(newQuiz.Id))
|
||||||
|
?? throw new Exception("could not find current module in quiz editor context");
|
||||||
|
|
||||||
|
var updatedModules = planner.LocalCourse.Modules
|
||||||
|
.Select(
|
||||||
|
m =>
|
||||||
|
m.Name == currentModule.Name
|
||||||
|
? currentModule with
|
||||||
|
{
|
||||||
|
Quizzes = currentModule.Quizzes
|
||||||
|
.Select(q => q.Id == newQuiz.Id ? newQuiz : q)
|
||||||
|
.ToArray()
|
||||||
|
}
|
||||||
|
: m
|
||||||
|
)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
planner.LocalCourse = planner.LocalCourse with { Modules = updatedModules };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user