@extends('layouts.admin')

@section('content')
  @php
    $questionSetCount = $questionsetupmanage->count();
    $activeQuestionSetCount = $questionsetupmanage->where('status', 1)->count();
  @endphp

  <div class="card-header">
    <h4>Manage Question Sets</h4>
    <a class="btn btn-primary float-right" href="{{ route('admin.addquestionsset') }}">Add Question Set</a>
  </div>

  <div class="card-body">
    @include('admin.partials.flash-messages')

    <div class="portal-page-shell">
      <div class="portal-hero-card">
        <div class="portal-hero-main">
          <div class="portal-hero-copy">
            <h5>Question Set Library</h5>
            <p>Combine ready question modules into complete exam sets for each class group and keep them organized from one place.</p>
            <div class="portal-chip-list">
              <span class="portal-chip">{{ $questionSetCount }} Total Sets</span>
              <span class="portal-chip">{{ $activeQuestionSetCount }} Active</span>
              <span class="portal-chip">5 Subject Mapping</span>
            </div>
          </div>
        </div>
      </div>

      <div class="portal-form-shell">
        <div class="table-responsive">
          <table class="table table-striped table-hover" id="tableExport" style="width:100%;">
            <thead>
              <tr>
                <th>#</th>
                <th>Question Set Title</th>
                <th>Question Class Group</th>
                <th>G.K. Question Set</th>
                <th>Science Question Set</th>
                <th>English Question Set</th>
                <th>Hindi Question Set</th>
                <th>Mathematics Question Set</th>
                <th>Status</th>
                <th>Action</th>
              </tr>
            </thead>
            <tbody>
              @forelse($questionsetupmanage as $questionSet)
                <tr>
                  <td>{{ $loop->iteration }}</td>
                  <td>{{ $questionSet->questionsettitle }}</td>
                  <td>{{ $questionSet->questionsetclassname }}</td>
                  <td>{{ $questionSet->questionsetgktitle }}</td>
                  <td>{{ $questionSet->questionsetsciencetittle }}</td>
                  <td>{{ $questionSet->questionsetenglishtitle }}</td>
                  <td>{{ $questionSet->questionsethindititle }}</td>
                  <td>{{ $questionSet->questionsetmathstitle }}</td>
                  <td>{{ (int) $questionSet->status === 1 ? 'Active' : 'In-Active' }}</td>
                  <td>
                    <a class="btn btn-success btn-sm" data-toggle="tooltip" data-placement="top" title="Edit Question Set" href="{{ route('admin.editquestionsset', ['id' => $questionSet->id]) }}">
                      <i class="fas fa-pencil-alt"></i>
                    </a>
                    <form action="{{ route('admin.deletequestionsset', ['id' => $questionSet->id]) }}" method="post" class="d-inline-block">
                      @csrf
                      <button type="submit" class="btn btn-danger deletedata" data-toggle="tooltip" data-placement="top" title="Delete Question Set" data-confirm-message="Are you sure you want to delete this question set?">
                        <i class="fas fa-trash"></i>
                      </button>
                    </form>
                  </td>
                </tr>
              @empty
                <tr>
                  <td colspan="10" class="text-center text-muted">No question sets are available right now.</td>
                </tr>
              @endforelse
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
@endsection
