@extends('layouts.app')
@section('title','Nhập điểm đánh giá')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-4"><div><h3 class="fw-bold mb-1">Nhập điểm đánh giá</h3><div class="text-muted">{{ $assessment->title }} - {{ $assessment->trainingClass->name ?? '' }}</div></div><a href="{{ route('assessments.index') }}" class="btn btn-outline-secondary">Quay lại</a></div>
@if(session('success'))<div class="alert alert-success">{{ session('success') }}</div>@endif
<div class="card shadow-sm"><div class="card-body"><form action="{{ route('assessments.save',$assessment->id) }}" method="POST">@csrf
<table class="table table-hover align-middle"><thead class="table-light"><tr><th>STT</th><th>Mã HV</th><th>Học viên</th><th>Điểm</th><th>Kết quả</th><th>Ghi chú</th></tr></thead><tbody>
@forelse($enrollments as $index=>$enrollment)
@php $result=$results[$enrollment->id] ?? null; @endphp
<tr><td>{{ $index+1 }}</td><td><strong>{{ $enrollment->student->code ?? '' }}</strong></td><td>{{ $enrollment->student->full_name ?? '' }}</td><td><input type="number" step="0.01" name="score[{{ $enrollment->id }}]" class="form-control" value="{{ $result->score ?? '' }}"></td><td>@if($result)<span class="badge {{ $result->result == 'Đạt' ? 'bg-success' : 'bg-danger' }}">{{ $result->result }}</span>@else<span class="text-muted">Chưa nhập</span>@endif</td><td><input type="text" name="note[{{ $enrollment->id }}]" class="form-control" value="{{ $result->note ?? '' }}"></td></tr>
@empty<tr><td colspan="6" class="text-center text-muted py-4">Lớp học này chưa có học viên đăng ký.</td></tr>@endforelse
</tbody></table><div class="text-end"><button class="btn btn-primary">Lưu kết quả</button></div></form></div></div>
@endsection
