ajoute le stock chaud, la correction automatique et les nouveaux essais de création de stack
Stock de stacks prêtes par lab dans Redis (prise atomique en Lua, ménage par comparaison avec Heat, disjoncteur), files gérées par Horizon, séances planifiables. Correcteur Go sur l'hyperviseur : socket Unix, commandes lues dans le lab.yaml uniquement, exécution par l'agent invité QEMU. Une création de stack ratée est supprimée et réessayée deux fois, puis la session passe en échec, visible du prof. Corrige aussi trois défauts des étapes précédentes : la console se coupait à la première frappe d'un navigateur (trames texte), l'élève ne pouvait pas rejoindre une séance, la déconnexion n'avait pas de jeton CSRF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ca2f6f3b7a
commit
80b6c0722d
71 changed files with 2959 additions and 170 deletions
|
|
@ -2,24 +2,27 @@
|
|||
|
||||
@section('titre', "Salle d'attente")
|
||||
|
||||
@php($etats = \App\Models\LabSession::class)
|
||||
|
||||
@section('contenu')
|
||||
@if ($labSession->etat === \App\Models\LabSession::EN_ATTENTE)
|
||||
<meta http-equiv="refresh" content="5">
|
||||
@endif
|
||||
<div class="mx-auto max-w-5xl px-5 py-14 lg:px-10">
|
||||
<p class="font-mono text-sm font-semibold">{{ $seance->lab->titre }}</p>
|
||||
@if ($labSession->etat === \App\Models\LabSession::EN_ATTENTE)
|
||||
@if ($labSession->etat === $etats::EN_ATTENTE)
|
||||
<div class="py-20 text-center">
|
||||
<h1 class="text-4xl font-extrabold tracking-tight">En attente que le prof t'admette…</h1>
|
||||
<p class="mt-4 font-semibold">Cette page se rafraîchit toute seule.</p>
|
||||
<p class="mt-4 font-semibold">Tes machines s'ouvriront ici dès qu'il t'aura admis.</p>
|
||||
</div>
|
||||
@elseif ($labSession->etat === \App\Models\LabSession::ADMIS)
|
||||
<meta http-equiv="refresh" content="4">
|
||||
@elseif ($labSession->etat === $etats::ADMIS)
|
||||
<div class="py-20 text-center">
|
||||
<h1 class="text-4xl font-extrabold tracking-tight">Préparation de tes VM…</h1>
|
||||
<p class="mt-4 font-semibold">Ça prend généralement moins d'une minute.</p>
|
||||
</div>
|
||||
@elseif ($labSession->machines->isNotEmpty())
|
||||
@elseif ($labSession->etat === $etats::ECHEC)
|
||||
<div class="py-20 text-center">
|
||||
<h1 class="text-4xl font-extrabold tracking-tight">Tes machines n'ont pas pu être préparées</h1>
|
||||
<p class="mt-4 font-semibold">Ton prof le voit et peut relancer. Cette page se mettra à jour toute seule.</p>
|
||||
</div>
|
||||
@elseif ($labSession->etat === $etats::ACTIF && $labSession->machines->isNotEmpty())
|
||||
<h1 class="mt-2 text-3xl font-extrabold tracking-tight">Tes machines</h1>
|
||||
<div class="mt-4 flex gap-2" role="tablist">
|
||||
@foreach ($labSession->machines as $i => $machine)
|
||||
|
|
@ -31,12 +34,43 @@
|
|||
<div id="terminal-{{ $machine->id }}" class="h-full"></div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<section class="mt-6 rounded-2xl border border-[#e3e5e8] bg-white p-6" aria-labelledby="t-verification">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h2 id="t-verification" class="text-2xl font-extrabold">Vérification</h2>
|
||||
<form action="{{ route('lab-sessions.corriger', $labSession) }}" method="post" id="form-verifier">
|
||||
@csrf
|
||||
<button type="submit" class="inline-flex h-11 items-center rounded-full bg-black px-5 font-bold text-white">Vérifier mon travail</button>
|
||||
</form>
|
||||
</div>
|
||||
@if (session('correction_indisponible'))
|
||||
<p class="mt-4 rounded-xl bg-[#fce8e6] p-3 font-semibold">La vérification est indisponible pour le moment. Réessaie dans une minute.</p>
|
||||
@endif
|
||||
@if ($correction = $labSession->derniereCorrection)
|
||||
<p class="mt-4 text-lg font-extrabold">
|
||||
{{ $correction->reussi ? 'Réussi' : 'Pas encore réussi' }}
|
||||
<span class="font-mono">· {{ $correction->note }}/{{ $correction->note_max }}</span>
|
||||
</p>
|
||||
<ul class="mt-3 grid gap-2">
|
||||
@foreach ($correction->details as $detail)
|
||||
<li class="rounded-xl border border-[#e3e5e8] p-3">
|
||||
<span class="font-mono font-bold">{{ $detail['reussi'] ? '✓' : '✗' }}</span>
|
||||
<span class="font-bold">{{ $detail['titre'] }}</span>
|
||||
<span class="font-mono text-sm">({{ $detail['points'] }} pt{{ $detail['points'] > 1 ? 's' : '' }})</span>
|
||||
@if ($detail['message'])
|
||||
<p class="mt-1 font-semibold text-[#A63D2A]">{{ $detail['message'] }}</p>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/css/xterm.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/lib/xterm.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-fit@0.10.0/lib/addon-fit.min.js"></script>
|
||||
<script src="{{ asset('js/console-reelle.js') }}"></script>
|
||||
<script>
|
||||
var monte = {};
|
||||
document.querySelectorAll('.onglet-machine').forEach(function (bouton) {
|
||||
bouton.addEventListener('click', function () {
|
||||
var id = bouton.dataset.onglet;
|
||||
|
|
@ -44,20 +78,39 @@
|
|||
document.querySelectorAll('[data-panneau]').forEach(function (p) { p.hidden = p.dataset.panneau !== id; });
|
||||
});
|
||||
});
|
||||
document.getElementById('form-verifier').addEventListener('submit', function (e) {
|
||||
var bouton = e.target.querySelector('button');
|
||||
bouton.disabled = true;
|
||||
bouton.textContent = 'Vérification en cours…';
|
||||
});
|
||||
@foreach ($labSession->machines as $machine)
|
||||
fetch('{{ route('console.eleve', [$labSession, $machine]) }}', {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
}).then(function (r) { return r.json(); }).then(function (d) {
|
||||
window.SyllabusConsoleReelle.mount(document.getElementById('terminal-{{ $machine->id }}'), { jeton: d.jeton, lectureSeule: false });
|
||||
window.SyllabusConsoleReelle.mount(document.getElementById('terminal-{{ $machine->id }}'), { jeton: d.jeton, lectureSeule: false, reveil: true });
|
||||
});
|
||||
@endforeach
|
||||
</script>
|
||||
@else
|
||||
<div class="py-20 text-center">
|
||||
<h1 class="text-4xl font-extrabold tracking-tight">La préparation a échoué</h1>
|
||||
<p class="mt-4 font-semibold">Préviens ton prof.</p>
|
||||
<h1 class="text-4xl font-extrabold tracking-tight">Cette séance est terminée pour toi</h1>
|
||||
<p class="mt-4 font-semibold">Tes machines ont été supprimées.</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if (in_array($labSession->etat, [$etats::EN_ATTENTE, $etats::ADMIS, $etats::ECHEC], true))
|
||||
<script>
|
||||
(function () {
|
||||
var etatAffiche = @json($labSession->etat);
|
||||
setInterval(function () {
|
||||
fetch('{{ route('seances.eleve.etat', $seance) }}', { headers: { 'Accept': 'application/json' } })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) { if (d.etat !== etatAffiche) location.reload(); })
|
||||
.catch(function () {});
|
||||
}, 1000);
|
||||
})();
|
||||
</script>
|
||||
@endif
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
@section('titre', "Salle d'attente")
|
||||
|
||||
@php($etats = \App\Models\LabSession::class)
|
||||
|
||||
@section('contenu')
|
||||
<meta http-equiv="refresh" content="10">
|
||||
<div class="mx-auto max-w-4xl px-5 py-14 lg:px-10">
|
||||
|
|
@ -14,20 +16,41 @@
|
|||
@else
|
||||
<ul class="mt-8 grid gap-3">
|
||||
@foreach ($seance->labSessions as $labSession)
|
||||
<li class="flex items-center justify-between gap-4 border border-[#e3e5e8] rounded-2xl bg-white p-4">
|
||||
<li class="flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-[#e3e5e8] bg-white p-4">
|
||||
<span class="font-extrabold">{{ $labSession->eleve->nomAffiche() }}</span>
|
||||
@if ($labSession->etat === \App\Models\LabSession::EN_ATTENTE)
|
||||
<form action="{{ route('seances.admettre', [$seance, $labSession]) }}" method="post">
|
||||
@csrf
|
||||
<button type="submit" class="inline-flex h-10 items-center rounded-full bg-[#0b57d0] px-4 font-bold text-white">Admettre</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="flex items-center gap-3">
|
||||
<span class="rounded-lg border border-[#dadce0] bg-[#e6f4ea] px-3 py-1 font-mono text-sm font-bold">Admis</span>
|
||||
@if ($labSession->machines->isNotEmpty())
|
||||
<span class="flex flex-wrap items-center gap-3">
|
||||
@switch($labSession->etat)
|
||||
@case($etats::EN_ATTENTE)
|
||||
<form action="{{ route('seances.admettre', [$seance, $labSession]) }}" method="post">
|
||||
@csrf
|
||||
<button type="submit" class="inline-flex h-10 items-center rounded-full bg-[#0b57d0] px-4 font-bold text-white">Admettre</button>
|
||||
</form>
|
||||
@break
|
||||
@case($etats::ADMIS)
|
||||
<span class="rounded-lg border border-[#dadce0] bg-[#fef7e0] px-3 py-1 font-mono text-sm font-bold">Préparation des VM…</span>
|
||||
@break
|
||||
@case($etats::ACTIF)
|
||||
<span class="rounded-lg border border-[#dadce0] bg-[#e6f4ea] px-3 py-1 font-mono text-sm font-bold">Admis</span>
|
||||
@if ($labSession->derniereCorrection)
|
||||
<span class="font-mono text-sm font-bold">
|
||||
{{ $labSession->derniereCorrection->reussi ? 'Réussi' : 'En cours' }} · {{ $labSession->derniereCorrection->note }}/{{ $labSession->derniereCorrection->note_max }}
|
||||
</span>
|
||||
@endif
|
||||
<a href="{{ route('seances.console.prof.page', [$seance, $labSession]) }}" class="font-bold underline underline-offset-4">Voir sa console</a>
|
||||
@endif
|
||||
</span>
|
||||
@break
|
||||
@case($etats::ECHEC)
|
||||
<span class="rounded-lg border border-[#A63D2A] bg-[#fce8e6] px-3 py-1 font-mono text-sm font-bold" title="{{ $labSession->raison_echec }}">Échec du lancement (3 essais)</span>
|
||||
<form action="{{ route('seances.admettre', [$seance, $labSession]) }}" method="post">
|
||||
@csrf
|
||||
<button type="submit" class="inline-flex h-10 items-center rounded-full bg-black px-4 font-bold text-white">Réessayer</button>
|
||||
</form>
|
||||
@break
|
||||
@default
|
||||
<span class="rounded-lg border border-[#dadce0] px-3 py-1 font-mono text-sm font-bold">Terminé</span>
|
||||
@endswitch
|
||||
</span>
|
||||
@if ($labSession->etat === $etats::ECHEC && $labSession->raison_echec)
|
||||
<p class="w-full font-mono text-xs text-[#5f6368]">{{ $labSession->raison_echec }}</p>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue