Files
Sistema-Educativo-Laravel/resources/views/tarea/mis_tareas.blade.php
T

154 lines
8.1 KiB
PHP

@extends('layouts.landing')
@section('head')
@include('layouts._partials.tablaStyle')
@endsection
@section('title', 'Mis Tareas')
@section('content')
<div class="container-fluid">
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Mis Tareas</h6>
</div>
<div class="card-body">
@if (session('info'))
<div class="alert alert-success"><strong>{{ session('info') }}</strong></div>
@endif
@if (session('error'))
<div class="alert alert-danger"><strong>{{ session('error') }}</strong></div>
@endif
@if ($errors->has('entrega'))
<div class="alert alert-warning"><strong>{{ $errors->first('entrega') }}</strong></div>
@endif
@if (!isset($tareas) || $tareas->isEmpty())
<div class="alert alert-info">No tienes tareas asignadas en tus grupos.</div>
@else
<div class="table-responsive">
<table id="tcont" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
<tr>
<th>Tarea</th>
<th>Materia</th>
<th>Grupo</th>
<th>Fecha límite</th>
<th>Status</th>
<th>Calificación</th>
<th>Tu entrega / Acción</th>
</tr>
</thead>
<tbody>
@foreach ($tareas as $tarea)
@php $entrega = $entregasMap[$tarea->id] ?? null; $status = $entrega?->status ?? 'sin_subir'; @endphp
<tr>
<td>
<strong>{{ $tarea->titulo }}</strong>
@if ($tarea->descripcion)
<p class="text-muted small mb-0">{{ Str::limit($tarea->descripcion, 80) }}</p>
@endif
</td>
<td>{{ $tarea->material->name }}</td>
<td>{{ $tarea->grupo->clave }}</td>
<td>
@if ($tarea->fecha_entrega)
{{ \Carbon\Carbon::parse($tarea->fecha_entrega)->format('d/m/Y') }}
@if (\Carbon\Carbon::parse($tarea->fecha_entrega)->isPast())
<span class="badge badge-danger">Vencida</span>
@else
<span class="badge badge-success">Activa</span>
@endif
@else
<span class="text-muted">Sin fecha</span>
@endif
</td>
<td>
@if ($status === 'sin_subir')
<span class="badge badge-secondary">Sin subir</span>
@elseif ($status === 'pendiente')
<span class="badge badge-warning">Pendiente</span>
@else
<span class="badge badge-success">Calificada</span>
@endif
</td>
<td>
@if ($status === 'calificada' && $entrega)
<strong class="text-success">{{ number_format($entrega->calificacion, 1) }}</strong>
@if ($entrega->comentario)
<br><small class="text-muted">{{ $entrega->comentario }}</small>
@endif
@else
<span class="text-muted"></span>
@endif
</td>
<td>
@if ($status === 'sin_subir')
{{-- Formulario de entrega: texto y/o archivo --}}
<form action="{{ route('tarea.entregar', $tarea) }}" method="POST"
enctype="multipart/form-data">
@csrf
<div class="form-group mb-1">
<textarea name="texto" class="form-control form-control-sm"
rows="3" placeholder="Escribe tu respuesta aquí (opcional)..."></textarea>
</div>
<div class="form-group mb-1">
<div class="custom-file">
<input type="file" class="custom-file-input" id="archivo_{{ $tarea->id }}" name="archivo">
<label class="custom-file-label small" for="archivo_{{ $tarea->id }}">
Adjuntar archivo (opcional)
</label>
</div>
</div>
<button type="submit" class="btn btn-primary btn-sm btn-block mt-1">
<i class="fas fa-upload fa-sm"></i> Entregar
</button>
</form>
@elseif ($status === 'pendiente' || $status === 'calificada')
{{-- Mostrar lo que entregó --}}
@if ($entrega?->texto)
<div class="border rounded p-2 bg-light mb-2" style="max-height:120px;overflow-y:auto;font-size:.85rem;">
{{ $entrega->texto }}
</div>
@endif
@if ($entrega?->archivo)
<a href="{{ route('files.serve', $entrega->archivo) }}"
target="_blank" class="btn btn-sm btn-outline-info">
<i class="fas fa-eye fa-sm"></i> Ver archivo entregado
</a>
@endif
@if (!$entrega?->texto && !$entrega?->archivo)
<span class="text-muted small">Sin contenido registrado</span>
@endif
@if ($status === 'pendiente')
<br><small class="text-warning"><i class="fas fa-clock"></i> Esperando calificación</small>
@endif
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>
@endsection
@section('scripts')
@include('layouts._partials.tablaScript')
<script>
document.querySelectorAll('.custom-file-input').forEach(input => {
input.addEventListener('change', function () {
const fileName = this.files[0]?.name || 'Adjuntar archivo (opcional)';
this.nextElementSibling.textContent = fileName;
});
});
</script>
@endsection