mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
FIX erreur resultat pour enseignant
This commit is contained in:
parent
e70d95d6b3
commit
aaf262db2a
1 changed files with 71 additions and 59 deletions
|
|
@ -70,27 +70,6 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
|
||||||
return classTotal / students.length;
|
return classTotal / students.length;
|
||||||
}, [students]);
|
}, [students]);
|
||||||
|
|
||||||
const getCorrectAnswersPerQuestion = (index: number): number => {
|
|
||||||
return (
|
|
||||||
(students.filter((student) =>
|
|
||||||
student.answers.some(
|
|
||||||
(answer) =>
|
|
||||||
parseInt(answer.idQuestion.toString()) === index + 1 && answer.isCorrect
|
|
||||||
)
|
|
||||||
).length / students.length) * 100
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const totalCorrectAnswers: number = useMemo(() => {
|
|
||||||
let classTotal = 0;
|
|
||||||
|
|
||||||
students.forEach((student) => {
|
|
||||||
classTotal += getTotalCorrectAnswers(student);
|
|
||||||
});
|
|
||||||
|
|
||||||
return classTotal;
|
|
||||||
}, [students]);
|
|
||||||
|
|
||||||
const getTotalCorrectAnswers = (student: StudentType): number => {
|
const getTotalCorrectAnswers = (student: StudentType): number => {
|
||||||
if (student.answers.length === 0) {
|
if (student.answers.length === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -114,16 +93,39 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
|
||||||
return correctAnswers;
|
return correctAnswers;
|
||||||
};
|
};
|
||||||
|
|
||||||
const totalParticipation: number = useMemo(() => {
|
const totalCorrectAnswers: number = useMemo(() => {
|
||||||
let classTotal = 0;
|
let classTotal = 0;
|
||||||
|
|
||||||
students.forEach((student) => {
|
students.forEach((student) => {
|
||||||
classTotal += getTotalAnswers(student);
|
classTotal += getTotalCorrectAnswers(student);
|
||||||
});
|
});
|
||||||
|
|
||||||
return (classTotal / (students.length * maxQuestions)) * 100;
|
return classTotal;
|
||||||
}, [students]);
|
}, [students]);
|
||||||
|
|
||||||
|
const getCorrectAnswersPerQuestion = (index: number): number => {
|
||||||
|
return (
|
||||||
|
(students.filter((student) =>
|
||||||
|
student.answers.some(
|
||||||
|
(answer) =>
|
||||||
|
parseInt(answer.idQuestion.toString()) === index + 1 && answer.isCorrect
|
||||||
|
)
|
||||||
|
).length / students.length) * 100
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTotalCorrectAnswersPerQuestion = (index: number): number => {
|
||||||
|
let total = 0;
|
||||||
|
students.filter((student)=>{
|
||||||
|
student.answers.forEach( (ans) =>{
|
||||||
|
if(parseInt(ans.idQuestion.toString()) === index + 1 && ans.isCorrect){
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return (total);
|
||||||
|
};
|
||||||
|
|
||||||
const getTotalAnswers = (student: StudentType): number => {
|
const getTotalAnswers = (student: StudentType): number => {
|
||||||
if (student.answers.length === 0) {
|
if (student.answers.length === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -143,6 +145,16 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
|
||||||
return answers;
|
return answers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const totalParticipation: number = useMemo(() => {
|
||||||
|
let classTotal = 0;
|
||||||
|
|
||||||
|
students.forEach((student) => {
|
||||||
|
classTotal += getTotalAnswers(student);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (classTotal / (students.length * maxQuestions)) * 100;
|
||||||
|
}, [students]);
|
||||||
|
|
||||||
const getParticipationPerQuestion = (index: number): number => {
|
const getParticipationPerQuestion = (index: number): number => {
|
||||||
return (
|
return (
|
||||||
(students.filter((student) =>
|
(students.filter((student) =>
|
||||||
|
|
@ -321,6 +333,41 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
|
||||||
{students.length > 0 ? `${classAverage.toFixed()} %` : '-'}
|
{students.length > 0 ? `${classAverage.toFixed()} %` : '-'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow sx={{ backgroundColor: '#d3d3d34f' }}>
|
||||||
|
<TableCell className="sticky-column" sx={{ color: 'black' }}>
|
||||||
|
<div className="text-base text-bold">% participation</div>
|
||||||
|
</TableCell>
|
||||||
|
{Array.from({ length: maxQuestions }, (_, index) => (
|
||||||
|
<TableCell
|
||||||
|
key={index}
|
||||||
|
sx={{
|
||||||
|
textAlign: 'center',
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: 'rgba(224, 224, 224, 1)',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
color: 'rgba(0, 0, 0)'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{students.length > 0
|
||||||
|
? `${getParticipationPerQuestion(index).toFixed()} %`
|
||||||
|
: '-'}
|
||||||
|
</TableCell>
|
||||||
|
))}
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
textAlign: 'center',
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: 'rgba(224, 224, 224, 1)',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
fontSize: '1rem',
|
||||||
|
color: 'rgba(0, 0, 0)'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{students.length > 0 ? `${totalParticipation.toFixed()} %` : '-'}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
<TableRow sx={{ backgroundColor: '#d3d3d34f' }}>
|
<TableRow sx={{ backgroundColor: '#d3d3d34f' }}>
|
||||||
<TableCell className="sticky-column" sx={{ color: 'black' }}>
|
<TableCell className="sticky-column" sx={{ color: 'black' }}>
|
||||||
<div className="text-base text-bold">Bonnes réponses</div>
|
<div className="text-base text-bold">Bonnes réponses</div>
|
||||||
|
|
@ -356,41 +403,6 @@ const LiveResults: React.FC<LiveResultsProps> = ({ questions, showSelectedQuesti
|
||||||
{students.length > 0 ? `${totalCorrectAnswers.toFixed()}` : '-'}
|
{students.length > 0 ? `${totalCorrectAnswers.toFixed()}` : '-'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow sx={{ backgroundColor: '#d3d3d34f' }}>
|
|
||||||
<TableCell className="sticky-column" sx={{ color: 'black' }}>
|
|
||||||
<div className="text-base text-bold">% réussite</div>
|
|
||||||
</TableCell>
|
|
||||||
{Array.from({ length: maxQuestions }, (_, index) => (
|
|
||||||
<TableCell
|
|
||||||
key={index}
|
|
||||||
sx={{
|
|
||||||
textAlign: 'center',
|
|
||||||
borderStyle: 'solid',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: 'rgba(224, 224, 224, 1)',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
color: 'rgba(0, 0, 0)'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{students.length > 0
|
|
||||||
? `${getParticipationPerQuestion(index).toFixed()} %`
|
|
||||||
: '-'}
|
|
||||||
</TableCell>
|
|
||||||
))}
|
|
||||||
<TableCell
|
|
||||||
sx={{
|
|
||||||
textAlign: 'center',
|
|
||||||
borderStyle: 'solid',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: 'rgba(224, 224, 224, 1)',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
fontSize: '1rem',
|
|
||||||
color: 'rgba(0, 0, 0)'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{students.length > 0 ? `${totalParticipation.toFixed()} %` : '-'}
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableFooter>
|
</TableFooter>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue