2024-03-29 20:08:34 -04:00
|
|
|
// LiveResults.tsx
|
2025-02-07 12:47:33 -05:00
|
|
|
import React, { useState } from 'react';
|
2024-03-29 20:08:34 -04:00
|
|
|
import { Socket } from 'socket.io-client';
|
|
|
|
|
import { QuestionType } from '../../Types/QuestionType';
|
|
|
|
|
import './liveResult.css';
|
|
|
|
|
import {
|
|
|
|
|
FormControlLabel,
|
|
|
|
|
FormGroup,
|
2025-03-18 13:36:42 -04:00
|
|
|
IconButton,
|
2024-03-29 20:08:34 -04:00
|
|
|
Switch,
|
|
|
|
|
} from '@mui/material';
|
2024-09-26 00:34:30 -04:00
|
|
|
import { StudentType } from '../../Types/StudentType';
|
2024-03-29 20:08:34 -04:00
|
|
|
|
2025-02-13 11:16:40 -05:00
|
|
|
import LiveResultsTable from './LiveResultsTable/LiveResultsTable';
|
2025-03-18 13:36:42 -04:00
|
|
|
import { ExpandLess, ExpandMore } from '@mui/icons-material';
|
2024-03-29 20:08:34 -04:00
|
|
|
|
|
|
|
|
interface LiveResultsProps {
|
|
|
|
|
socket: Socket | null;
|
|
|
|
|
questions: QuestionType[];
|
|
|
|
|
showSelectedQuestion: (index: number) => void;
|
|
|
|
|
quizMode: 'teacher' | 'student';
|
2024-09-26 00:34:30 -04:00
|
|
|
students: StudentType[]
|
2024-03-29 20:08:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 00:34:30 -04:00
|
|
|
const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuestion, students }) => {
|
2024-03-29 20:08:34 -04:00
|
|
|
const [showUsernames, setShowUsernames] = useState<boolean>(false);
|
|
|
|
|
const [showCorrectAnswers, setShowCorrectAnswers] = useState<boolean>(false);
|
2025-03-18 13:36:42 -04:00
|
|
|
const [isExpanded, setIsExpanded] = useState<boolean>(true);
|
|
|
|
|
|
|
|
|
|
const toggleExpand = () => {
|
|
|
|
|
setIsExpanded(!isExpanded);
|
|
|
|
|
};
|
2024-03-29 20:08:34 -04:00
|
|
|
|
|
|
|
|
return (
|
2025-02-05 11:50:42 -05:00
|
|
|
|
|
|
|
|
|
2024-03-29 20:08:34 -04:00
|
|
|
<div>
|
|
|
|
|
<div className="action-bar mb-1">
|
2025-03-18 13:36:42 -04:00
|
|
|
<div>
|
|
|
|
|
<IconButton onClick={toggleExpand} aria-label="toggle visibility">
|
|
|
|
|
{isExpanded ? <ExpandLess /> : <ExpandMore />}
|
|
|
|
|
</IconButton>
|
|
|
|
|
<span>Résultats du quiz</span>
|
|
|
|
|
</div>
|
|
|
|
|
{isExpanded && (
|
2024-03-29 20:08:34 -04:00
|
|
|
<FormGroup row>
|
|
|
|
|
<FormControlLabel
|
|
|
|
|
label={<div className="text-sm">Afficher les noms</div>}
|
|
|
|
|
control={
|
|
|
|
|
<Switch
|
|
|
|
|
value={showUsernames}
|
|
|
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
|
|
|
setShowUsernames(e.target.checked)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<FormControlLabel
|
|
|
|
|
label={<div className="text-sm">Afficher les réponses</div>}
|
|
|
|
|
control={
|
|
|
|
|
<Switch
|
|
|
|
|
value={showCorrectAnswers}
|
|
|
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
|
|
|
setShowCorrectAnswers(e.target.checked)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</FormGroup>
|
2025-03-18 13:36:42 -04:00
|
|
|
)}
|
2024-03-29 20:08:34 -04:00
|
|
|
</div>
|
2025-03-18 13:36:42 -04:00
|
|
|
{isExpanded && (
|
2024-09-24 09:49:15 -04:00
|
|
|
<div className="table-container">
|
2024-09-26 00:34:30 -04:00
|
|
|
|
2025-02-12 14:01:36 -05:00
|
|
|
<LiveResultsTable
|
|
|
|
|
students={students}
|
|
|
|
|
questions={questions}
|
|
|
|
|
showCorrectAnswers={showCorrectAnswers}
|
|
|
|
|
showSelectedQuestion={showSelectedQuestion}
|
|
|
|
|
showUsernames={showUsernames}
|
|
|
|
|
/>
|
2024-09-26 00:34:30 -04:00
|
|
|
</div>
|
2025-03-18 13:36:42 -04:00
|
|
|
)}
|
2024-09-24 09:49:15 -04:00
|
|
|
</div>
|
2024-03-29 20:08:34 -04:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LiveResults;
|