<div class="m-0 p-0">
@if($testy->isEmpty())
    <div class="row justify-content-center">
        <div class="card card-lg text-center">
            <div class="card-body">
                <i class="fa fa-list-alt fa-8x opacity-20 p-2"></i>
                <h1 class="h5">Nenašli sa žiadne testy...</h1>
            </div>
        </div>
    </div>
@else
    <div class="card card-sm shadow">
        <div class="card-header bg-secondary d-flex justify-content-between align-items-center">
            <div>
                <span class="text-muted text-small">Počet položiek {{ ($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>
            <form class="d-flex align-items-center">
                <span class="mr-2 text-muted text-small text-nowrap">Zoradiť:</span>
                <select class="custom-select" wire:model="sort">
                    <option value="1">najstaršie</option>
                    <option value="0">najnovšie</option>
                </select>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table align-items-center mb-0">
                <thead>
                <tr>
                    <th scope="col">#</th>
                    <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">
                        <td>{{ ($testy->currentPage() * $testy->perPage()) - $testy->perPage() + $loop->index + 1 }}.</td>
                        <td>
                            <span class="text-dark">{{ $test->nazov }}</span>
                        </td>
                        <td class="text-center">{{ $test->pouzivatel->meno }} <span class="badge badge-light">{{ $test->pouzivatel->login }}</span></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) }}">
                                    Zobraziť
                                    <i class="icon-right-open"></i>
                                </a>
                            @else
                                <a class="btn btn-md btn-primary btn-block" href="{{ route('vzdelavanie.testy.pouzivatela.test.spustenie', $test) }}">
                                    <i class="icon-play"></i>
                                    Dokončiť
                                </a>
                            @endif
                        </td>
                    </tr>
                    @if($loop->remaining)
                        <tr class="table-divider"></tr>
                    @endif
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endif

@if($testy->isNotEmpty() && $testy->hasPages())
    <div class="d-flex justify-content-center">
        {{ $testy->links() }}
    </div>
@endif
</div>

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