Fix CBT history react-markdown crash, fix test deletion cascade, fix cbt theme, add 180 NEET questions
This commit is contained in:
@@ -118,6 +118,37 @@ export default function AttemptHistoryPage({ params }: { params: Promise<{ attem
|
||||
const q = questions[ans.question_id];
|
||||
if (!q) return null;
|
||||
|
||||
const getUserAnswerText = () => {
|
||||
if (ans.is_subjective || q.type === 'Subjective' || q.type === 'Numerical') {
|
||||
if (Array.isArray(ans.selected_answer)) {
|
||||
return ans.selected_answer.join(", ");
|
||||
}
|
||||
return String(ans.selected_answer || 'Not Attempted');
|
||||
}
|
||||
if (Array.isArray(ans.selected_answer)) {
|
||||
return ans.selected_answer.map((val: any) => q.options && q.options[val] ? `**${val})** ${q.options[val]}` : val).join("\n\n");
|
||||
}
|
||||
return q.options && q.options[ans.selected_answer]
|
||||
? `**${ans.selected_answer})** ${q.options[ans.selected_answer]}`
|
||||
: String(ans.selected_answer || 'Not Attempted');
|
||||
};
|
||||
|
||||
const getCorrectAnswerText = () => {
|
||||
const rawCorrect = q.correct_answer?.correct || q.correct_answer?.value || q.correct_answer?.selected;
|
||||
if (ans.is_subjective || q.type === 'Subjective' || q.type === 'Numerical') {
|
||||
if (Array.isArray(rawCorrect)) {
|
||||
return rawCorrect.join(", ");
|
||||
}
|
||||
return String(rawCorrect || 'Subjective text');
|
||||
}
|
||||
if (Array.isArray(rawCorrect)) {
|
||||
return rawCorrect.map((val: any) => q.options && q.options[val] ? `**${val})** ${q.options[val]}` : val).join("\n\n");
|
||||
}
|
||||
return q.options && q.options[rawCorrect]
|
||||
? `**${rawCorrect})** ${q.options[rawCorrect]}`
|
||||
: String(rawCorrect || 'N/A');
|
||||
};
|
||||
|
||||
return (
|
||||
<Card key={ans.question_id} className={`border-l-4 ${ans.is_correct ? 'border-l-green-500' : 'border-l-red-500'}`}>
|
||||
<CardContent className="p-6">
|
||||
@@ -150,9 +181,7 @@ export default function AttemptHistoryPage({ params }: { params: Promise<{ attem
|
||||
<p className="text-sm font-bold text-muted-foreground uppercase">Your Answer</p>
|
||||
<div className={`p-3 rounded-lg border prose prose-sm dark:prose-invert ${ans.is_correct ? 'bg-green-500/10 border-green-500/30 text-green-500' : 'bg-red-500/10 border-red-500/30 text-red-500'}`}>
|
||||
<ReactMarkdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>
|
||||
{ans.is_subjective || q.type === 'Subjective' || q.type === 'Numerical'
|
||||
? (ans.selected_answer || 'Not Attempted')
|
||||
: (q.options && q.options[ans.selected_answer] ? `${ans.selected_answer}) ${q.options[ans.selected_answer]}` : ans.selected_answer || 'Not Attempted')}
|
||||
{getUserAnswerText()}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
@@ -160,11 +189,7 @@ export default function AttemptHistoryPage({ params }: { params: Promise<{ attem
|
||||
<p className="text-sm font-bold text-muted-foreground uppercase">Correct Answer</p>
|
||||
<div className="p-3 rounded-lg border bg-green-500/10 border-green-500/30 text-green-500 prose prose-sm dark:prose-invert">
|
||||
<ReactMarkdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>
|
||||
{ans.is_subjective || q.type === 'Subjective' || q.type === 'Numerical'
|
||||
? (q.correct_answer?.value || q.correct_answer?.correct || q.correct_answer?.selected || 'Subjective text')
|
||||
: (q.options && q.options[q.correct_answer?.correct || q.correct_answer?.value || q.correct_answer?.selected]
|
||||
? `${q.correct_answer?.correct || q.correct_answer?.value || q.correct_answer?.selected}) ${q.options[q.correct_answer?.correct || q.correct_answer?.value || q.correct_answer?.selected]}`
|
||||
: (q.correct_answer?.correct || q.correct_answer?.value || q.correct_answer?.selected || 'N/A'))}
|
||||
{getCorrectAnswerText()}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user