mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
added quiz support, improved assignment description and rubric support
This commit is contained in:
@@ -137,6 +137,7 @@
|
||||
@oninput="handleNewDescription"
|
||||
/>
|
||||
</div>
|
||||
<QuizSettings />
|
||||
|
||||
@foreach(var question in quizContext.Quiz.Questions)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,9 @@
|
||||
{
|
||||
if (quizContext.Quiz != null)
|
||||
{
|
||||
var newPoints = int.Parse(e.Value?.ToString() ?? "0");
|
||||
var pointsString = e.Value?.ToString() ?? "0";
|
||||
|
||||
var newPoints = int.Parse(pointsString == string.Empty ? "0" : pointsString);
|
||||
var newQuestion = Question with
|
||||
{
|
||||
Points = newPoints
|
||||
@@ -123,28 +125,20 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
@foreach(var typeOption in QuestionType.AllTypes)
|
||||
{
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="@(Question.Id + "question_type")"
|
||||
id="@(Question.Id + typeOption)"
|
||||
value="@typeOption"
|
||||
checked="@(typeOption == questionType)"
|
||||
@onchange="() => handleTypeUpdate(typeOption)"
|
||||
>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="@(Question.Id + typeOption)"
|
||||
>
|
||||
@typeOption
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@foreach (var typeOption in QuestionType.AllTypes)
|
||||
{
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="@(Question.Id + "question_type")"
|
||||
id="@(Question.Id + typeOption)" value="@typeOption" checked="@(typeOption == questionType)"
|
||||
@onchange="() => handleTypeUpdate(typeOption)">
|
||||
<label class="form-check-label" for="@(Question.Id + typeOption)">
|
||||
@typeOption
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
<div class="mb-3 row">
|
||||
<div class="col-auto">
|
||||
<label
|
||||
@@ -166,15 +160,6 @@
|
||||
|
||||
@if(questionType == QuestionType.MULTIPLE_ANSWERS || questionType == QuestionType.MULTIPLE_CHOICE)
|
||||
{
|
||||
|
||||
@foreach(var answer in answers)
|
||||
{
|
||||
<EditableQuizAnswer
|
||||
Answer="answer"
|
||||
SaveAnswer="saveAnswer"
|
||||
Question="Question"
|
||||
/>
|
||||
}
|
||||
<button
|
||||
class="btn btn-outline-danger"
|
||||
@onclick="removeAnswer"
|
||||
@@ -187,6 +172,15 @@
|
||||
>
|
||||
+ Add Answer
|
||||
</button>
|
||||
|
||||
@foreach(var answer in answers)
|
||||
{
|
||||
<EditableQuizAnswer
|
||||
Answer="answer"
|
||||
SaveAnswer="saveAnswer"
|
||||
Question="Question"
|
||||
/>
|
||||
}
|
||||
|
||||
}
|
||||
<div>
|
||||
|
||||
74
Management.Web/Shared/Components/Quiz/QuizSettings.razor
Normal file
74
Management.Web/Shared/Components/Quiz/QuizSettings.razor
Normal file
@@ -0,0 +1,74 @@
|
||||
@using Management.Web.Shared.Components
|
||||
|
||||
@inject QuizEditorContext quizContext
|
||||
|
||||
@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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<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>
|
||||
</div>
|
||||
Reference in New Issue
Block a user