    
<?php $__env->startSection('content'); ?>
  <?php
    $contestType = $contest_type ?? 'paid';
    $contestTypeLabel = $contest_type_label ?? ($contestType === 'free' ? 'Free Exam' : 'Paid Competition');
    $isFreeModule = $contestType === 'free';
    $moduleTitle = $assignment_title ?? 'Manage Assign Competitions';
    $moduleNote = $assignment_note ?? 'Use filter to quickly inspect assignments for one class group.';
    $addRouteName = $assign_add_route_name ?? 'admin.addassigncompetition';
    $filterRouteName = $assign_route_name ?? 'admin.assigncompetition';
    $editRouteName = $assign_edit_route_name ?? 'admin.editassigncompetition';
    $upcomingAssignments = $compitetionassignment->filter(fn ($assignment) => $assignment->examdate && $assignment->examdate->isFuture())->count();
  ?>

  <div class="card-header">
    <h4><?php echo e($moduleTitle); ?></h4>
    <a class="btn btn-primary float-right" href="<?php echo e(route($addRouteName)); ?>"><?php echo e($isFreeModule ? 'Add Free Exam Assignment' : 'Add Assignment'); ?></a>
  </div>
  <div class="card-body">
    <?php echo $__env->make('admin.partials.flash-messages', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <div class="contest-summary">
      <div class="contest-summary-item">
        <span>Total Assignments</span>
        <strong><?php echo e(number_format($compitetionassignment->count())); ?></strong>
      </div>
      <div class="contest-summary-item">
        <span>Filtered Group</span>
        <strong><?php echo e($selectedGroupId > 0 ? $studentsgroup->firstWhere('id', $selectedGroupId)?->studentsgroupname : 'All Groups'); ?></strong>
      </div>
      <div class="contest-summary-item">
        <span>Upcoming Exams</span>
        <strong><?php echo e(number_format($upcomingAssignments)); ?></strong>
      </div>
    </div>

    <form action="<?php echo e(route($filterRouteName)); ?>">
      <div class="portal-form-grid">
        <div class="form-group portal-form-group">
          <label for="questiongoupsclass">Class Group</label>
          <select name="goupsclass" id="questiongoupsclass" class="form-control">
            <option value="">Select Class Group</option>
            <?php $__currentLoopData = $studentsgroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $group): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option value="<?php echo e($group->id); ?>" <?php if($selectedGroupId === (int) $group->id): echo 'selected'; endif; ?>><?php echo e($group->studentsgroupname); ?></option> 
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </select>
        </div>
        <div class="portal-form-actions">
          <p class="portal-inline-note"><?php echo e($moduleNote); ?></p>
          <div>
            <button type="submit" id="subnmitbutton" class="btn btn-primary">Search</button>
            <a class="btn btn-danger" href="<?php echo e(route($filterRouteName)); ?>">Clear All</a>
          </div>
        </div>
      </div>
    </form>

    <div class="table-responsive">
      <table class="table table-striped table-hover" id="tableExport" style="width:100%;">
        <thead>
          <tr>
            <th>#</th>
            <th>Assignment Title</th>
            <th>Class Group</th>
            <th>Board</th>
            <th>Question Sets</th>
            <th><?php echo e($isFreeModule ? 'Free Exam' : 'Competition'); ?></th>
            <th>Schedule</th>
            <th>Exam End Time</th>
            <th>Action</th>
          </tr>
        </thead>
        <tbody>
          <?php $__currentLoopData = $compitetionassignment; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assignment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
              <td><?php echo e($loop->iteration); ?></td>
              <td>
                <strong><?php echo e($assignment->compitetiontitle); ?></strong>
                <div class="table-subtext">Result: <?php echo e($assignment->resultdate?->format('d-m-Y') ?? '-'); ?></div>
              </td>
              <td><?php echo e($assignment->groupclassname); ?></td>
              <td><?php echo e($assignment->boardpatternname); ?></td>
              <td><?php echo e($assignment->questiomnsetname); ?></td>
              <td><?php echo e($assignment->compitetionname); ?></td>
              <td>
                <div>Start: <?php echo e($assignment->startdate?->format('d-m-Y') ?? '-'); ?></div>
                <div class="table-subtext">End: <?php echo e($assignment->enddate?->format('d-m-Y') ?? '-'); ?> | Exam: <?php echo e($assignment->examdate?->format('d-m-Y') ?? '-'); ?></div>
              </td>
              <td><?php echo e($assignment->examendtime ? date('h:i A', strtotime($assignment->examendtime)) : '-'); ?></td>
              <td class="contest-actions">
                <a class="btn btn-success btn-sm" data-toggle="tooltip" data-placement="top" title="Edit Assignment" href="<?php echo e(route($editRouteName, ['id' => $assignment->id])); ?>">
                  <i class='fas fa-pencil-alt'></i>
                </a>
                <form action="<?php echo e(route('admin.deleteassigncompetition', ['id' => $assignment->id])); ?>" method="post" class="d-inline-block">
                  <?php echo csrf_field(); ?>
                  <button type="submit" class="btn btn-danger deletedata" data-toggle="tooltip" data-placement="top" title="Delete Assign Competition" data-confirm-message="Are you sure you want to delete this assigned competition?">
                    <i class='fas fa-trash'></i>
                  </button>
                </form>
              </td>
            </tr>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
      </table>
    </div>
  </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\examproject\examproject_new\resources\views/admin/assigncompitetions/assigncompetition.blade.php ENDPATH**/ ?>