@page
@model Quizzer.Pages.QuizzesModel
@{
    ViewData["Title"] = "Quizzer";
    Layout = "_Layout-teacher";
}
<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12" style="background-color: lightgreen">
            <h1><center>Quizz Management</center></h1>
        </div>
    </div>
    <div class=row>
        <div class="col-xl-12" style="background-color: lemonchiffon">
            <table>
                <tr>
                    <td>
                        Select Category
                    </td>
                    <td>
                        <form class="form-horizontal" method="post">
                            <input type="hidden" name="action" value="changeCategory" />
                            @Html.Raw(Model.CategorySelect)
                        </form>
                    </td>
                </tr>
                <tr>
                    <td>
                        Select Class
                    </td>
                    <td>
                        <form class="form-horizontal" method="post">
                            <input type="hidden" name="action" value="changeClass" />
                            <select name="target" onchange="javascript:this.form.submit()">
                                <option value=""> Select the Class </option>
                                @foreach (var item in @Model.TheClassList)
                                {
                                    @if (item == Model.pageQuizz.Class)
                                    {
                                        <option value="@item" selected> @item </option>
                                    }
                                    else
                                    {
                                        <option value="@item"> @item </option>
                                    }
                                }
                            </select>
                        </form>
                    </td>
                </tr>
            </table>
            <form class="form-horizontal" method="post">
                @*
                <label for="newQuizz_Class" class="form-label">Class</label>
                @Html.TextBoxFor(m => m.pageQuizz.Class)
                @Html.DropDownListFor(m => m.pageQuizz.Class, new SelectList(Model.TheClassList), "Select the Class")
                *@
                <br />
                <label for="newQuizz_Descr" class="form-label">Description</label>
                @Html.TextAreaFor(m => m.pageQuizz.Descr, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" })<br />
                <label for="newQuizz_Anonymous" class="form-label">Anonymous quiz</label>
                @Html.CheckBoxFor(m => m.pageQuizz.Anonymous)<br />
                <label for="newQuizz_Qsize" class="form-label">Number of questions</label>
                @Html.TextBoxFor(m => m.pageQuizz.QSize, new { @type = "number" })
                <button type="submit" class="btn btn-primary" name="action" value="createQuizz">Submit</button>
            </form>
        </div>
    </div>
    <div class=row>
        <div class="col-xl-12" style="background-color: lightgreen">
            <h5>Tests in system</h5>
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>Class</th>
                        <th>Size</th>
                        <th>Category</th>
                        <th>Anonymous</th>
                        <th>Description</th>
                    </tr>
                </thead>
                @foreach (var item in @Model.QuizzList)
                {
                <tr>
                    <td>
                        @item.Class
                    </td>
                    <td>
                        @item.QSize
                    </td>
                    <td>
                        @item.CategoryText
                    </td>
                    <td>
                        @item.Anonymous
                    </td>
                    <td>
                        @item.Descr
                    </td>
                    <td>
                        <form asp-page="" method="post">
                            <input type="hidden" name="action" value="delete" />
                            <input type="hidden" name="target" value="@item.QuizzId" />
                            <button type="submit" class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
                        </form>
                    </td>
                </tr>
                }
            </table>
        </div>
    </div>
</div>