mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
105 lines
2.6 KiB
Plaintext
105 lines
2.6 KiB
Plaintext
@using Management.Web.Shared.Components
|
|
@using Management.Web.Shared.Components.Forms
|
|
|
|
@inject QuizEditorContext quizContext
|
|
@inject CoursePlanner planner
|
|
|
|
@code {
|
|
protected override void OnInitialized()
|
|
{
|
|
quizContext.StateHasChanged += reload;
|
|
}
|
|
private void reload()
|
|
{
|
|
if (quizContext.Quiz != null)
|
|
{
|
|
if (!lockAtDueDate)
|
|
lockAtDueDate = quizContext.Quiz.LockAtDueDate;
|
|
if (lockAt == null)
|
|
lockAt = quizContext.Quiz.LockAt;
|
|
if (!shuffleAnswers)
|
|
shuffleAnswers = quizContext.Quiz.ShuffleAnswers;
|
|
if (!oneQuestionAtATime)
|
|
oneQuestionAtATime = quizContext.Quiz.OneQuestionAtATime;
|
|
if (allowedAttempts == 0)
|
|
allowedAttempts = quizContext.Quiz.AllowedAttempts;
|
|
|
|
this.InvokeAsync(this.StateHasChanged);
|
|
}
|
|
}
|
|
public void Dispose()
|
|
{
|
|
quizContext.StateHasChanged -= reload;
|
|
}
|
|
|
|
private bool lockAtDueDate { get; set; }
|
|
private DateTime? lockAt { get; set; }
|
|
private bool shuffleAnswers { get; set; }
|
|
private bool oneQuestionAtATime { get; set; }
|
|
private int allowedAttempts { get; set; }
|
|
|
|
private void handleLockAtDueDateChange()
|
|
{
|
|
if(quizContext.Quiz == null)
|
|
return;
|
|
|
|
var newValue = !quizContext.Quiz.LockAtDueDate;
|
|
|
|
var newQuiz = newValue
|
|
? quizContext.Quiz with
|
|
{
|
|
LockAtDueDate = newValue,
|
|
LockAt = quizContext.Quiz.DueAt
|
|
}
|
|
: quizContext.Quiz with
|
|
{
|
|
LockAtDueDate = newValue
|
|
};
|
|
quizContext.SaveQuiz(newQuiz);
|
|
}
|
|
|
|
private void setAssignmentGroup(LocalAssignmentGroup group)
|
|
{
|
|
if(quizContext.Quiz == null)
|
|
return;
|
|
|
|
var newQuiz = quizContext.Quiz with
|
|
{
|
|
LocalAssignmentGroupId = group.Id
|
|
};
|
|
|
|
quizContext.SaveQuiz(newQuiz);
|
|
}
|
|
|
|
private LocalAssignmentGroup? selectedAssignmentGroup =>
|
|
planner
|
|
.LocalCourse?
|
|
.AssignmentGroups
|
|
.FirstOrDefault(g => g.Id == quizContext.Quiz?.LocalAssignmentGroupId);
|
|
}
|
|
@if(planner.LocalCourse != null )
|
|
{
|
|
<div>
|
|
<div class="form-check form-switch">
|
|
<input
|
|
class="form-check-input"
|
|
type="checkbox"
|
|
role="switch"
|
|
id="lockAtDueDate"
|
|
checked="@lockAtDueDate"
|
|
@onchange="handleLockAtDueDateChange">
|
|
<label
|
|
class="form-check-label" for="lockAtDueDate">
|
|
Lock at Due Date
|
|
</label>
|
|
</div>
|
|
<ButtonSelect
|
|
Label="Assignment Group"
|
|
Options="planner.LocalCourse.AssignmentGroups"
|
|
GetId="(g) => g.Id"
|
|
GetName="(g) => g.Name"
|
|
OnSelect="(g) => setAssignmentGroup(g)"
|
|
SelectedOption="selectedAssignmentGroup"
|
|
/>
|
|
</div>
|
|
} |