'use client'; import { Box, Grid, Typography, LinearProgress } from '@mui/material'; import { detailStyles } from '../detailStyles'; import { useTranslation } from 'react-i18next'; const QUESTION_TYPE_LABELS = { true_false: 'eval.questionTypes.true_false', single_choice: 'eval.questionTypes.single_choice', multiple_choice: 'eval.questionTypes.multiple_choice', short_answer: 'eval.questionTypes.short_answer', open_ended: 'eval.questionTypes.open_ended' }; export default function EvalStats({ stats, currentFilter, onFilterSelect }) { const { t } = useTranslation(); if (!stats?.byType || Object.keys(stats.byType).length === 0) return null; return ( {Object.entries(stats.byType).map(([type, typeStats]) => { const accuracy = typeStats.total > 0 ? (typeStats.correct / typeStats.total) * 100 : 0; const isSelected = currentFilter === type; return ( onFilterSelect(isSelected ? null : type)} sx={{ ...detailStyles.typeStatsItem, cursor: 'pointer', transition: 'all 0.2s', bgcolor: isSelected ? 'primary.light' : '#fff', borderColor: isSelected ? 'primary.main' : '#eee', '&:hover': { transform: 'translateY(-2px)', boxShadow: '0 4px 12px rgba(0,0,0,0.1)', borderColor: 'primary.main' }, '& *': { color: isSelected ? 'primary.contrastText' : undefined } }} > {t(QUESTION_TYPE_LABELS[type] || type)} {typeStats.correct} / {typeStats.total} = 60 ? 'success' : 'error'} /> {accuracy.toFixed(0)}% ); })} ); }