From fc433edf4fc4a11a5461b2b828ebdfe9c7475e79 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 27 Jun 2026 20:28:38 -0700 Subject: [PATCH] feat: Add Correct/Incorrect badge to rationale --- src/components/quizzes/QuizViewer.tsx | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/components/quizzes/QuizViewer.tsx b/src/components/quizzes/QuizViewer.tsx index f348fbe..dec1689 100644 --- a/src/components/quizzes/QuizViewer.tsx +++ b/src/components/quizzes/QuizViewer.tsx @@ -358,16 +358,40 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu {/* Rationale shown after submission */} - {isSubmitted && ( -
-

Rationale

-
+ {isSubmitted && (() => { + const formattedQ = { + id: currentQ.id, + type: currentQ.type as "MULTIPLE_CHOICE" | "SATA", + options: currentQ.options, + }; + const qScore = scoreQuestion(formattedQ, currentSelections); + let badgeText = "Incorrect"; + let badgeColor = "bg-error text-white"; + + if (qScore === 1) { + badgeText = "Correct"; + badgeColor = "bg-success text-white"; + } else if (qScore > 0) { + badgeText = "Partially Correct"; + badgeColor = "bg-amber-500 text-white"; + } + + return ( +
+
+

Rationale

+ + {badgeText} + +
+
{currentQ.rationale}
- )} + ); + })()}
{/* Action bar */}