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']);
|
$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', [
|
return Inertia::render('Candidate/QuizInterface', [
|
||||||
'quiz' => $quiz,
|
'quiz' => $quizData,
|
||||||
'attempt' => $attempt->load('answers')
|
'attempt' => $attempt->load('answers'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,8 +150,10 @@ const finishQuiz = () => {
|
|||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<main class="flex-1 flex flex-col items-center justify-center p-8">
|
<main class="flex-1 flex flex-col items-center justify-center p-8">
|
||||||
<div class="w-full max-w-3xl">
|
<div class="w-full max-w-3xl">
|
||||||
<!-- Guard: wait until question is loaded -->
|
<!-- Guard: only render if quiz has questions -->
|
||||||
<div v-if="!currentQuestion" class="text-center text-slate-400 italic">Chargement de la question...</div>
|
<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 -->
|
<!-- 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">
|
<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