@model MultipleChoiceTrainer.Models.DataModels.Question

@{
    ViewData["Title"] = "Frage Anlegen";
}

<h4>Frage anlegen</h4>
<p class="text-black-50">in Lektion <i>@ViewBag.Section.Name</i>, Kurs <i>@ViewBag.Section.Category.Name</i></p>
<hr />
<div class="row">
    <div class="col-md-12">
        <form asp-action="Create">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <input type="hidden" asp-for="SectionId" value="@ViewBag.Section.Id" />
            <div class="form-group row">
                <label asp-for="Text" class="control-label col-2"></label>
                <input asp-for="Text" class="form-control col-10" />
                <span asp-validation-for="Text" class="text-danger offset-2"></span>
            </div>
            <div class="form-group row">
                <label asp-for="Choices" class="control-label col-2"></label>
                <div class="col-10 row">
                    @for (int i = 0; i < 5; i++)
                    {
                    <div class="row col-12 mb-1 px-0 mx-0">
                        @if (Model != null && Model.Choices != null && Model.Choices.Count > i)
                        {
                            <input asp-for="@Model.Choices[i].Text" class="form-control col-10" />
                            <div class="form-check col-2 text-right">
                                <input asp-for="@Model.Choices[i].IsTrue" class="form-check-input" value="true" />
                                <label asp-for="@Model.Choices[i].IsTrue" class="form-check-label">Richtig</label>
                            </div>
                        }
                        else
                        {
                            <input type="text" name="Choices[@i].Text" class="form-control col-10" />
                            <div class="form-check col-2 text-right">
                                <input type="checkbox" name="Choices[@i].IsTrue" id="CheckBox-IsTrue-@i" class="form-check-input" value="true" />
                                <label for="CheckBox-IsTrue-@i" class="form-check-label">Richtig</label>
                            </div>
                        }
                    </div>
                    }
                    <span asp-validation-for="Choices" class="text-danger" ></span>
                </div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
                <a asp-action="Index" asp-controller="Home" asp-route-categoryId="@ViewBag.Section.CategoryId" class="btn btn-outline-danger"><i class="fas fa-times"></i> Abbrechen</a>
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="Index">Back to List</a>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
