This commit is contained in:
@@ -25,6 +25,20 @@ export function ExamPaperPreview({ title, subject, grade, durationMin, totalScor
|
||||
// Helper to flatten questions for continuous numbering
|
||||
let questionCounter = 0
|
||||
|
||||
const parseContent = (raw: unknown): QuestionContent => {
|
||||
if (raw && typeof raw === "object") return raw as QuestionContent
|
||||
if (typeof raw === "string") {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as unknown
|
||||
if (parsed && typeof parsed === "object") return parsed as QuestionContent
|
||||
return { text: raw }
|
||||
} catch {
|
||||
return { text: raw }
|
||||
}
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
const renderNode = (node: ExamNode, depth: number = 0) => {
|
||||
if (node.type === 'group') {
|
||||
return (
|
||||
@@ -45,7 +59,7 @@ export function ExamPaperPreview({ title, subject, grade, durationMin, totalScor
|
||||
if (node.type === 'question' && node.question) {
|
||||
questionCounter++
|
||||
const q = node.question
|
||||
const content = q.content as QuestionContent
|
||||
const content = parseContent(q.content)
|
||||
|
||||
return (
|
||||
<div key={node.id} className="mb-6 break-inside-avoid">
|
||||
|
||||
Reference in New Issue
Block a user