diff --git a/MultipleChoiceTrainer/Controllers/QuizController.cs b/MultipleChoiceTrainer/Controllers/QuizController.cs index 690bec9..70e12bd 100644 --- a/MultipleChoiceTrainer/Controllers/QuizController.cs +++ b/MultipleChoiceTrainer/Controllers/QuizController.cs @@ -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); } } } \ No newline at end of file diff --git a/MultipleChoiceTrainer/Models/DataModels/Evaluation.cs b/MultipleChoiceTrainer/Models/DataModels/Evaluation.cs new file mode 100644 index 0000000..fa06565 --- /dev/null +++ b/MultipleChoiceTrainer/Models/DataModels/Evaluation.cs @@ -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; } + } +} diff --git a/MultipleChoiceTrainer/Models/QuizViewModel.cs b/MultipleChoiceTrainer/Models/QuizViewModel.cs index 335b46a..ab126b4 100644 --- a/MultipleChoiceTrainer/Models/QuizViewModel.cs +++ b/MultipleChoiceTrainer/Models/QuizViewModel.cs @@ -20,6 +20,12 @@ namespace MultipleChoiceTrainer.Models public Question CurrentQuestion { get; set; } - public IList Choices { get; set; } + public IList 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 Evaluations { get; set; } } } diff --git a/MultipleChoiceTrainer/Views/Quiz/Quiz.cshtml b/MultipleChoiceTrainer/Views/Quiz/Quiz.cshtml index 16d61de..05ebe52 100644 --- a/MultipleChoiceTrainer/Views/Quiz/Quiz.cshtml +++ b/MultipleChoiceTrainer/Views/Quiz/Quiz.cshtml @@ -6,20 +6,27 @@ @using (Html.BeginForm("quiz", "quiz", FormMethod.Post)) { + + +

Frage beantworten

aus Lektion @Model.CurrentQuestion.Section.Name, Kurs @Model.CurrentQuestion.Section.Category.Name


- @Model.CurrentQuestion.Text + @Model.CurrentQuestion.Text

@for(int i = 0; i < Model.Choices.Count(); i++) { - +
+ +
} + + } diff --git a/MultipleChoiceTrainer/Views/Shared/_Layout.cshtml b/MultipleChoiceTrainer/Views/Shared/_Layout.cshtml index 427f066..9bc57cc 100644 --- a/MultipleChoiceTrainer/Views/Shared/_Layout.cshtml +++ b/MultipleChoiceTrainer/Views/Shared/_Layout.cshtml @@ -41,6 +41,11 @@ + @RenderSection("Scripts", required: false)