Quiz weiter gebaut;
This commit is contained in:
@@ -70,9 +70,20 @@ namespace MultipleChoiceTrainer.Controllers
|
||||
|
||||
public IActionResult Quiz(QuizViewModel viewModel)
|
||||
{
|
||||
var newViewModel = new QuizViewModel()
|
||||
{
|
||||
QuizType = viewModel.QuizType,
|
||||
CurrentTypeId = viewModel.CurrentTypeId
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(viewModel.CurrentQuestion.Text))
|
||||
{
|
||||
|
||||
return View("quiz", viewModel);
|
||||
}
|
||||
|
||||
GetQuestion(newViewModel);
|
||||
|
||||
return View("quiz", newViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
MultipleChoiceTrainer/Models/DataModels/Evaluation.cs
Normal file
16
MultipleChoiceTrainer/Models/DataModels/Evaluation.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MultipleChoiceTrainer.Models.DataModels
|
||||
{
|
||||
public class Evaluation
|
||||
{
|
||||
public bool Success => RightAnswer == GivenAnswer;
|
||||
public bool RightAnswer { get; set; }
|
||||
public bool GivenAnswer { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,11 @@ namespace MultipleChoiceTrainer.Models
|
||||
public Question CurrentQuestion { get; set; }
|
||||
|
||||
public IList<Choice> Choices { get; set; }
|
||||
|
||||
|
||||
public bool HasPreviousResult => (Evaluations != null && Evaluations.Any());
|
||||
public bool PassedPreviousQuestion => HasPreviousResult && !Evaluations.Any(e => !e.Success);
|
||||
public string PreviousQuestion { get; set; }
|
||||
public IList<Evaluation> Evaluations { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,20 +6,27 @@
|
||||
@using (Html.BeginForm("quiz", "quiz", FormMethod.Post))
|
||||
{
|
||||
<input asp-for="QuizType" type="hidden" />
|
||||
<input asp-for="CurrentTypeId" type="hidden" />
|
||||
|
||||
<input asp-for="CurrentQuestion.Id" type="hidden" />
|
||||
|
||||
<h4>Frage beantworten</h4>
|
||||
<p class="text-black-50">aus Lektion <i>@Model.CurrentQuestion.Section.Name</i>, Kurs <i>@Model.CurrentQuestion.Section.Category.Name</i></p>
|
||||
<hr />
|
||||
<p class="lead">
|
||||
@Model.CurrentQuestion.Text
|
||||
@Model.CurrentQuestion.Text <small class="text-black-50"> <i class="fas fa-info-circle" data-toggle="tooltip" title="(@Model.CurrentQuestion.Choices.Count(e => e.IsTrue) von @Model.Choices.Count())"></i></small>
|
||||
</p>
|
||||
@for(int i = 0; i < Model.Choices.Count(); i++)
|
||||
{
|
||||
|
||||
<div class="form-check">
|
||||
<input asp-for="@Model.Choices[i].Id" type="hidden" />
|
||||
<input asp-for="@Model.Choices[i].Text" type="hidden" />
|
||||
<input asp-for="@Model.Choices[i].IsTrue" class="form-check-input" value="true" />
|
||||
<label asp-for="@Model.Choices[i].IsTrue" class="form-check-label">@Model.Choices[i].Text</label>
|
||||
</div>
|
||||
}
|
||||
|
||||
<button type="submit" class="btn btn-outline-warning">Prüfen</button>
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
})
|
||||
</script>
|
||||
@RenderSection("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user