fix: quiz questions not showing - reload quiz freshly in show(), fix v-if guard in QuizInterface
This commit is contained in:
@@ -76,11 +76,15 @@ class AttemptController extends Controller
|
||||
$candidate->update(['status' => 'en_cours']);
|
||||
}
|
||||
|
||||
$quiz->load(['questions.options']);
|
||||
// Reload quiz with questions FRESHLY (avoid any cached state from model binding)
|
||||
$quizData = Quiz::with(['questions' => function($q) {
|
||||
$q->orderBy('id')->with('options');
|
||||
}])
|
||||
->find($quiz->id);
|
||||
|
||||
return Inertia::render('Candidate/QuizInterface', [
|
||||
'quiz' => $quiz,
|
||||
'attempt' => $attempt->load('answers')
|
||||
'quiz' => $quizData,
|
||||
'attempt' => $attempt->load('answers'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,10 @@ const finishQuiz = () => {
|
||||
<!-- Main Content -->
|
||||
<main class="flex-1 flex flex-col items-center justify-center p-8">
|
||||
<div class="w-full max-w-3xl">
|
||||
<!-- Guard: wait until question is loaded -->
|
||||
<div v-if="!currentQuestion" class="text-center text-slate-400 italic">Chargement de la question...</div>
|
||||
<!-- Guard: only render if quiz has questions -->
|
||||
<div v-if="!quiz.questions || !quiz.questions.length" class="text-center py-12">
|
||||
<p class="text-slate-400 italic">Aucune question disponible pour ce test.</p>
|
||||
</div>
|
||||
|
||||
<!-- Question Card -->
|
||||
<div v-else class="bg-slate-800/50 backdrop-blur-xl rounded-3xl p-8 sm:p-12 border border-slate-700 shadow-2xl relative overflow-hidden group">
|
||||
|
||||
Reference in New Issue
Block a user