added points to quiz editor

This commit is contained in:
2023-08-18 10:02:25 -06:00
parent 28ad344018
commit a962ef74f9
6 changed files with 77 additions and 13 deletions

View File

@@ -15,11 +15,14 @@
if(answers.Count() == 0)
answers = Question.Answers;
if (points == 0)
points = Question.Points;
base.OnParametersSet();
}
private string text { get; set; } = string.Empty;
private string questionType { get; set; } = string.Empty;
private int points { get; set; }
private IEnumerable<LocalQuizQuestionAnswer> answers { get; set; } = Enumerable.Empty<LocalQuizQuestionAnswer>();
private void handleTypeUpdate(string type)
@@ -35,6 +38,18 @@
UpdateQuestion(newQuestion);
}
}
private void handlePointsInput(ChangeEventArgs e)
{
if (quizContext.Quiz != null)
{
var newPoints = int.Parse(e.Value?.ToString() ?? "0");
var newQuestion = Question with
{
Points = newPoints
};
UpdateQuestion(newQuestion);
}
}
private void addAnswer()
{
@@ -130,6 +145,23 @@
}
</div>
</div>
<div class="mb-3 row">
<div class="col-auto">
<label
for="exampleInputEmail1"
class="form-label"
>
Points
</label>
<input
type="number"
class="form-control"
id="exampleInputEmail1"
@bind="points"
@oninput="handlePointsInput"
>
</div>
</div>
<div>Answers:</div>
@if(questionType == QuestionType.MULTIPLE_ANSWERS || questionType == QuestionType.MULTIPLE_CHOICE)