import React from 'react' import { motion } from 'framer-motion' import { CheckCircle, XCircle, AlertCircle } from 'lucide-react' const Question = ({ question, questionNumber, selectedAnswer, onAnswer, showResult, result }) => { const options = ['A', 'B', 'C', 'D'] const getOptionStyle = (option) => { if (!showResult) { return selectedAnswer === option ? 'border-primary-500 bg-primary-50 ring-4 ring-primary-100' : 'border-slate-200 hover:border-primary-300 hover:bg-primary-50' } // Show results if (option === question.correct_answer) { return 'border-green-500 bg-green-50 ring-4 ring-green-100' } if (option === selectedAnswer && option !== question.correct_answer) { return 'border-red-500 bg-red-50 ring-4 ring-red-100' } return 'border-slate-200 opacity-50' } const getOptionIcon = (option) => { if (!showResult) return null if (option === question.correct_answer) { return } if (option === selectedAnswer && option !== question.correct_answer) { return } return null } return ( {/* Question Header */} {questionNumber} {question.question} {question.difficulty && ( {question.difficulty} )} {/* Options */} {options.map((option, index) => ( !showResult && onAnswer(option)} disabled={showResult} className={`w-full p-4 rounded-xl border-2 transition-all text-left flex items-center gap-4 ${getOptionStyle(option)} ${ showResult ? 'cursor-default' : 'cursor-pointer' }`} > {option} {question.options[option]} {getOptionIcon(option)} ))} {/* Explanation */} {showResult && result && ( {result.is_correct ? ( ) : ( )} {result.is_correct ? 'Correct!' : 'Incorrect'} {result.explanation} {result.new_knowledge_level !== undefined && ( Knowledge Level Updated {Math.round(result.new_knowledge_level * 100)}% )} )} ) } export default Question
{result.explanation}