@@ -19,7 +19,15 @@ const questionResults = ref<QuestionResult[]>([])
1919const quizCompleted = ref (false )
2020const finalResult = ref <FinalizeQuizMutation [' finalizeQuiz' ] | null >(null )
2121const startedSubmission = ref <StartQuizMutation [' startQuiz' ] | null >(null )
22- const isLoading = ref (false )
22+
23+ // Start with loading true if we need to start a quiz (no active submission and can start)
24+ const needsToStartQuiz = computed (() => {
25+ return (
26+ ! props .challenge .quiz .userActiveSubmission ?.id &&
27+ props .challenge .quiz .userCanStart
28+ )
29+ })
30+ const isLoading = ref (needsToStartQuiz .value )
2331
2432// Check if user has a completed submission (quiz already taken)
2533const completedSubmission = computed (() => {
@@ -46,8 +54,7 @@ const canStartQuiz = computed(() => {
4654
4755onMounted (async () => {
4856 // If there's no active submission and we can start, start the quiz
49- if (! props .challenge .quiz .userActiveSubmission ?.id && canStartQuiz .value ) {
50- isLoading .value = true
57+ if (needsToStartQuiz .value ) {
5158 const result = await startQuiz ({
5259 quizId: props .challenge .quiz .id ,
5360 })
@@ -165,5 +172,22 @@ async function handleAnswerSubmitted(result: QuestionResult) {
165172 :question =" currentQuestion"
166173 />
167174 </template >
175+
176+ <!-- Fallback: show completed submission result even if retakes are allowed -->
177+ <template v-else-if =" completedSubmission " >
178+ <QuizResult
179+ :score =" completedSubmission.score ?? 0"
180+ :max-score =" completedSubmission.maxScore ?? 0"
181+ :points-awarded =" completedSubmission.pointsAwarded ?? 0"
182+ :results =" completedSubmissionResults"
183+ />
184+ </template >
185+
186+ <!-- Final fallback: show loading for any unexpected state -->
187+ <template v-else >
188+ <div class =" flex items-center justify-center grow" >
189+ <LoadingState />
190+ </div >
191+ </template >
168192 </PageLayout >
169193</template >
0 commit comments