fix: smart CBT result/back routing for DPPs and add Test Type selector in Admin panel

This commit is contained in:
2026-07-27 15:55:54 +05:30
parent 053b727725
commit 62d15c85f6
5 changed files with 40 additions and 7 deletions

View File

@@ -19,11 +19,15 @@ interface ExamAttemptPayload {
interface ExamResultProps {
payload: ExamAttemptPayload;
attemptId: string | null;
examType?: string; // 'CBT' or 'DPS'
onRetake: () => void;
}
export function ExamResult({ payload, attemptId, onRetake }: ExamResultProps) {
export function ExamResult({ payload, attemptId, examType, onRetake }: ExamResultProps) {
const router = useRouter();
const isDPP = examType === 'DPS';
const backRoute = isDPP ? '/dashboard/ai-coach/cbt-dpp' : '/dashboard/cbt';
const backLabel = isDPP ? 'Back to PrepPilot AI' : 'Back to Mock Tests';
const answered = payload.answers.filter(a => a.selected_answer !== null).length;
const unanswered = payload.total_questions - answered;
@@ -114,7 +118,7 @@ export function ExamResult({ payload, attemptId, onRetake }: ExamResultProps) {
<div className="flex flex-col sm:flex-row gap-4 justify-center pt-8">
<Button variant="outline" size="lg" className="rounded-xl h-14 px-8 font-bold text-lg gap-2" onClick={onRetake}>
<RotateCcw className="size-5" /> Retake Mock Test
<RotateCcw className="size-5" /> {isDPP ? 'Retake DPP' : 'Retake Mock Test'}
</Button>
{attemptId && (
<Button
@@ -146,10 +150,10 @@ export function ExamResult({ payload, attemptId, onRetake }: ExamResultProps) {
} catch (err) {
console.error("Error exiting fullscreen", err);
}
router.push("/dashboard/cbt");
router.push(backRoute);
}}
>
Dashboard <ArrowRight className="size-5" />
{backLabel} <ArrowRight className="size-5" />
</Button>
</div>