@extends('Vzdelavanie::layout.integrated')

@section('content')
    @parent
    <section class="bg-white space-sm">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col">
                    <h1 class="h2 mb-2">História testov všetkých študentov</h1>
                    <span>Zoznam spustených testov všetkých študentov</span>
                </div>
            </div>
        </div>
    </section>

    <section>
        <div class="container">
            <div class="row">
                <div class="col">
                @if($testy->isEmpty())
                    <div class="alert alert-primary text-small">
                        <i class="icon-info mr-2"></i>
                        Zatiaľ neexistujú žiadne testy...
                    </div>
                @else
                    <div class="d-flex justify-content-between align-items-center mb-4">
                        <div>
                            <span class="text-muted text-small">Výsledky {{ ($testy->currentPage() * $testy->perPage()) - $testy->perPage() + 1 }} - @if($testy->total() > ($testy->currentPage() * $testy->perPage())) {{ $testy->currentPage() * $testy->perPage() }} @else {{ $testy->total() }} @endif z {{ $testy->total() }}</span>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-borderless align-items-center">
                            <thead>
                            <tr>
                                <th scope="col">Názov testu</th>
                                <th scope="col" class="text-center">Používateľ</th>
                                <th scope="col" class="text-center">Úspešnosť</th>
                                <th scope="col" class="text-center">Spustené</th>
                                <th scope="col" class="text-center">Vyhodnotené</th>
                                <th scope="col" class="text-center">Akcia</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($testy as $test)
                                <tr class="bg-white">
                                    <th>
                                        <span class="text-dark">{{ $test->nazov }}</span>
                                    </th>
                                    <td class="text-center">{{ $test->pouzivatel->meno }} [{{ $test->pouzivatel->pracovisko->kod }}]</td>
                                    <td>
                                        <div class="progress progress-sm">
                                            <div class="progress-bar bg-success" role="progressbar" style="width: {{ $test->spravneZodpovedaneOtazkyPercentualne }}%" aria-valuenow="{{ $test->spravneZodpovedaneOtazkyPercentualne }}" aria-valuemin="0" aria-valuemax="100" data-toggle="tooltip" data-placement="top" title="Podiel správne zodpovedaných otázok"></div>
                                            <div class="progress-bar bg-danger" role="progressbar" style="width: {{ $test->nespravneZodpovedaneOtazkyPercentualne }}%" aria-valuenow="{{ $test->nespravneZodpovedaneOtazkyPercentualne }}" aria-valuemin="0" aria-valuemax="100" data-toggle="tooltip" data-placement="top" title="Podiel nesprávne zodpovedaných otázok"></div>
                                        </div>
                                    </td>
                                    <td class="text-center">{{ $test->casova_znacka_spustenia ? $test->casova_znacka_spustenia->format('d.m.Y H:i:s') : '-' }}</td>
                                    <td class="text-center">{{ $test->casova_znacka_vyhodnotenia ? $test->casova_znacka_vyhodnotenia->format('d.m.Y H:i:s') : '-' }}</td>
                                    <td class="w-auto">
                                        @if($test->jeVyhodnoteny())
                                            <a class="btn btn-md btn-success btn-block" href="{{ route('vzdelavanie.testy.pouzivatela.test.vyhodnotenie', $test) }}">
                                                Vyhodnotenie
                                                <i class="icon-chevron-right"></i>
                                            </a>
                                        @else
                                            <a class="btn btn-md btn-primary btn-block" href="{{ route('vzdelavanie.testy.pouzivatela.test.spustenie', $test) }}">
                                                <i class="icon-controller-play"></i>
                                                Pokračovať
                                            </a>
                                        @endif
                                    </td>
                                </tr>
                                @if($loop->remaining)
                                    <tr class="table-divider"></tr>
                                @endif
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    @endif
                </div>
            </div>
            @if($testy->count() && $testy->hasPages())
                <div class="row">
                    <div class="col-12 d-flex justify-content-center">
                        {{ $testy->onEachSide(5)->links() }}
                    </div>
                </div>
            @endif
        </div>
    </section>
@endsection

@push('scripts')
    <script type="text/javascript">
      $(function () {
        $('[data-toggle="tooltip"]').tooltip()
      })
    </script>
@endpush