@page
@model Quizzer.Pages.StatisticsModel
@Html.AntiForgeryToken()
@{
    ViewData["Title"] = "Quizzer";
    Layout = "_Layout-teacher";
}
<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12" style="background-color: lightgreen">
            <h1><center>Statistics</center></h1>
        </div>
    </div>
    <div class="row">
        <div class="col-xl-12">
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th></th>
                        <th>Class</th>
                        <th>Quizz</th>
                    </tr>
                </thead>
                @foreach (var item in Model.quizzList)
                {
                    <tr>
                        <td>
                            <form class="form-horizontal" method="post">
                                <input type="hidden" name="action" value="selectQuizz" />
                                <input type="hidden" name="changeTo" value="@item.QuizzId" />
                                <button type="button" class="btn btn-outline-primary" onclick="javascript:this.form.submit()">Stats</button>
                            </form>
                        </td>
                        <td>@item.Class</td>
                        <td>@item.CategoryText</td>
                        <td>
                            <form asp-page="" method="post">
                                <input type="hidden" name="action" value="delete" />
                                <input type="hidden" name="changeTo" 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>
    @if (Model.PageStatistics != null)
    {
        @if (Model.PageStatistics.Questions.Count > 0 && Model.PageStatistics.MCList.Count > 0)
        {
            <div class="row">
                <h3>Statistics</h3><br>
                @for (int Qindex = 0; Qindex < Model.PageStatistics.Questions.Count; Qindex++)
                {
                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th style="width: 10%">Count</th>
                                <th>@Model.PageStatistics.Questions[Qindex].QuestionText</th>
                            </tr>
                        </thead>
                        @for (int Aindex = 0; Aindex < @Model.PageStatistics.Questions[Qindex].AList.Count; Aindex++)
                        {
                            <tr>
                                <td class="align-text-top">@Model.PageStatistics.MCList[Qindex].Counter[Aindex]</td>
                                @if (@Model.PageStatistics.Questions[Qindex].AList[Aindex].Aok)
                                {
                                    <td style="background-color:lightgreen">@Model.PageStatistics.Questions[Qindex].AList[Aindex].Atxt</td>
                                }
                                else
                                {
                                    <td>@Model.PageStatistics.Questions[Qindex].AList[Aindex].Atxt</td>
                                }
                            </tr>
                        }
                    </table>
                }
            </div>
        }
    }
    <div class="row">
    </div>
</div>
