generated from muhtadeetaron/nextjs-template
fix(ui): fix timer reappearing after exam submission
This commit is contained in:
@ -27,8 +27,9 @@ export default function ExamPage() {
|
||||
if (fetchedTest?.metadata.time_limit_minutes) {
|
||||
resetTimer(fetchedTest.metadata.time_limit_minutes * 60, () => {
|
||||
// Timer ended → auto-submit exam
|
||||
stopTimer();
|
||||
submitExam(type);
|
||||
router.push(`/categories/${type}s`);
|
||||
router.push(`/exam/results`);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -56,6 +57,7 @@ export default function ExamPage() {
|
||||
|
||||
const handleSubmitExam = async (type: string) => {
|
||||
try {
|
||||
stopTimer();
|
||||
setIsSubmitting(true);
|
||||
await submitExam(type);
|
||||
router.push(`/exam/results`);
|
||||
|
||||
@ -15,7 +15,7 @@ export default function ResultsPage() {
|
||||
if (!result) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center">
|
||||
<p className="text-lg font-medium">No results to display.</p>
|
||||
<p className="text-lg font-medium">Redirecting...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -46,16 +46,19 @@ export default function ResultsPage() {
|
||||
const correctAnswer = result.correct_answers[idx];
|
||||
|
||||
return (
|
||||
<div key={q.question_id} className={`rounded-3xl mb-6`}>
|
||||
<div key={q.question_id} className="rounded-3xl mb-6">
|
||||
<QuestionItem
|
||||
question={q}
|
||||
index={idx}
|
||||
selectedAnswer={userAnswer}
|
||||
onSelect={() => {}} // disabled in results
|
||||
onSelect={() => {}}
|
||||
userAnswer={userAnswer}
|
||||
correctAnswer={correctAnswer}
|
||||
showResults={true}
|
||||
/>
|
||||
|
||||
{/* Answer feedback */}
|
||||
<div className="mt-2 text-sm">
|
||||
{/* Optional answer feedback below the question */}
|
||||
{/* <div className="mt-2 text-sm">
|
||||
{userAnswer === null ? (
|
||||
<span className="text-yellow-600 font-medium">
|
||||
Skipped — Correct: {String.fromCharCode(65 + correctAnswer)}
|
||||
@ -68,7 +71,7 @@ export default function ResultsPage() {
|
||||
Correct Answer: {String.fromCharCode(65 + correctAnswer)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user