Bearbeitung von Fragen

This commit is contained in:
2020-06-10 13:23:29 +02:00
parent 6d84a4614b
commit a8b04a6443
11 changed files with 205 additions and 34 deletions

View File

@@ -29,7 +29,7 @@
<ul class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">@sub.Name <small class="text-muted">@sub.Description</small></h5>
<small>@sub.Questions.Count() Fragen</small>
<small><a asp-action="list" asp-controller="questions" asp-route-sectionId="@sub.Id" class="text-decoration-none text-black-50">@sub.Questions.Count() Fragen</a></small>
</div>
<p class="text-black-50">
<a asp-action="edit" asp-controller="Sections" asp-route-id="@sub.Id" class="text-black-50"><i class="far fa-edit"></i> Lektion bearbeiten</a> &nbsp;&nbsp;&nbsp;

View File

@@ -12,33 +12,37 @@
<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">
<label asp-for="Text" class="control-label"></label>
<input asp-for="Text" class="form-control" />
<span asp-validation-for="Text" class="text-danger"></span>
<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">
<label asp-for="Choices" class="control-label"></label>
@if (Model != null && Model.Choices != null)
{
@for (int i = 0; i < Model.Choices.Count; i++)
<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="text-center">
<input asp-for="@Model.Choices[i].Text" class="form-control" />
<input asp-for="@Model.Choices[i].IsTrue" class="form-control" />
</div>
<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>
}
}
else
{
<input type="hidden" name="Choices.Index" value="10" />
<input type="text" name="Choices[10].Text" class="form-control" />
<input type="checkbox" name="Choices[10].IsTrue" class="form-control" value="true" />
<input type="hidden" name="Choices.Index" value="11" />
<input type="text" name="Choices[11].Text" class="form-control" />
<input type="checkbox" name="Choices[11].IsTrue" class="form-control" value="true" />
}
<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>

View File

@@ -13,9 +13,41 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="SectionId" />
<div class="form-group">
<label asp-for="Text" class="control-label"></label>
<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].Id" type="hidden" />
<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>

View File

@@ -0,0 +1,37 @@
@model IEnumerable<MultipleChoiceTrainer.Models.DataModels.Question>
@{
ViewData["Title"] = "Fragen";
}
<table class="table table-hover">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Text)
</th>
<th>
@Html.DisplayNameFor(model => model.Choices)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Text)
</td>
<td>
@foreach (var choice in item.Choices)
{
<i class="@if (choice.IsTrue) { <text>fas fa-check text-success</text> } else { <text>fas fa-times text-danger</text> }"></i> @choice.Text<br />
}
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id"><i class="fas fa-edit"></i> Bearbeiten</a>
</td>
</tr>
}
</tbody>
</table>