35 lines
981 B
PHP
35 lines
981 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers;
|
||
|
|
|
||
|
|
use App\Models\LabSession;
|
||
|
|
use App\Services\Labs\CorrigerSession;
|
||
|
|
use Illuminate\Http\RedirectResponse;
|
||
|
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
use Illuminate\Support\Facades\Log;
|
||
|
|
use RuntimeException;
|
||
|
|
|
||
|
|
class CorrectionController extends Controller
|
||
|
|
{
|
||
|
|
public function corriger(LabSession $labSession, CorrigerSession $correction): RedirectResponse
|
||
|
|
{
|
||
|
|
abort_if($labSession->eleve_id !== Auth::guard('eleve')->id(), 403);
|
||
|
|
|
||
|
|
$retour = redirect()->route('seances.eleve.attente', $labSession->seance_id);
|
||
|
|
|
||
|
|
if ($labSession->etat !== LabSession::ACTIF) {
|
||
|
|
return $retour;
|
||
|
|
}
|
||
|
|
|
||
|
|
try {
|
||
|
|
$correction->corriger($labSession);
|
||
|
|
} catch (RuntimeException $e) {
|
||
|
|
Log::error("Correction impossible pour la session {$labSession->id}", ['raison' => $e->getMessage()]);
|
||
|
|
|
||
|
|
return $retour->with('correction_indisponible', true);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $retour;
|
||
|
|
}
|
||
|
|
}
|