From 464b179df991783fb3751d2a755a8844b99685f4 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 28 Jun 2026 08:24:32 -0700 Subject: [PATCH] feat: Redesign quiz viewer to match academic textbook aesthetic --- src/components/quizzes/QuizViewer.tsx | 169 ++++++++++++++------------ 1 file changed, 88 insertions(+), 81 deletions(-) diff --git a/src/components/quizzes/QuizViewer.tsx b/src/components/quizzes/QuizViewer.tsx index 2a56a0b..a852093 100644 --- a/src/components/quizzes/QuizViewer.tsx +++ b/src/components/quizzes/QuizViewer.tsx @@ -260,85 +260,99 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu return
Question not found.
; } + const categories = Array.from(new Set(quiz.questions.map(q => q.category.toUpperCase()))).join(" ยท "); + return (
- {/* Running Score Header */} -
-
- Progress: - {currentIndex + 1} / {order.length} -
-
- Score so far: - - {parseFloat(runningScore.toFixed(2))} / {maxPossibleSoFar} - + + {/* Title & Meta */} +
+

+ {quiz.name} +

+
+ {categories}
- {/* Question Card */} -
+ {/* Main Unified Card */} +
- {/* Header (Type & Category) */} -
- - {currentQ.type === "MULTIPLE_CHOICE" ? "Multiple Choice" : "Select All That Apply"} - - - {currentQ.category} - + {/* Progress Header */} +
+
+ Q {currentIndex + 1} / {order.length} +
+
+
+
+
+ Score: {parseFloat(runningScore.toFixed(2))} / {maxPossibleSoFar} +
-
-
+ {/* Question Area */} +
+ + {/* Tags */} +
+ + {currentQ.category} + + + {currentQ.type === "MULTIPLE_CHOICE" ? "Multiple Choice" : "Select All That Apply"} + +
+ + {/* Prompt */} +
{currentQ.prompt}
-
+ {/* Options */} +
{(shuffledOptions[currentQId] || currentQ.options).map((opt) => { const isSelected = currentSelections.includes(opt.id); - let stateClass = "border-border hover:border-primary/50 cursor-pointer"; - let icon = null; - + let stateClass = "border-border-light hover:border-border cursor-pointer"; + if (isSubmitted) { stateClass = "cursor-default opacity-80"; if (opt.isCorrect) { - stateClass = "border-success bg-success-bg/30 text-text-heading"; - icon = ( - - - - ); + stateClass = "border-success bg-success-bg text-text-heading"; } else if (isSelected && !opt.isCorrect) { - // Selected incorrectly - stateClass = "border-error bg-error-bg/30 text-text-heading"; - icon = ( - - - - ); + stateClass = "border-error bg-error-bg text-text-heading"; } else { - // Not selected, not correct - stateClass = "border-border-light bg-bg-surface-alt/50"; + stateClass = "border-border-light"; } } else if (isSelected) { - stateClass = "border-primary bg-primary/5 ring-1 ring-primary"; + stateClass = "border-primary bg-primary/5"; } return (
toggleOption(opt.id)} - className={`flex items-start gap-4 p-4 rounded-xl border-2 transition-all duration-200 ${stateClass}`} + className={`flex items-center gap-4 px-5 py-4 rounded-xl border transition-all duration-200 ${stateClass}`} > -
+
{isSelected && ( - + + + + )} + {!isSelected && isSubmitted && opt.isCorrect && ( + )} @@ -347,11 +361,6 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu
{opt.text}
- {icon && ( -
- {icon} -
- )}
); })} @@ -393,13 +402,10 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu return (
- {/* Result Banner */}
{icon} {badgeText}
- - {/* Rationale Box */}

Rationale

@@ -411,33 +417,34 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu
); })()} -
- {/* Action bar */} -
- {!isSubmitted ? ( - - ) : currentIndex + 1 < order.length ? ( - - ) : ( - - )} + {/* Action Button */} +
+ {!isSubmitted ? ( + + ) : currentIndex + 1 < order.length ? ( + + ) : ( + + )} +
+