mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
1 commit
498d7d2c1c
...
b0d798ec10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0d798ec10 |
2 changed files with 3 additions and 71 deletions
|
|
@ -152,7 +152,7 @@ describe('LiveResults', () => {
|
||||||
expect(classAverageElement).toBeInTheDocument();
|
expect(classAverageElement).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('displays the correct answers per question in %', () => {
|
test('displays the correct answers per question', () => {
|
||||||
render(
|
render(
|
||||||
<LiveResults
|
<LiveResults
|
||||||
socket={mockSocket}
|
socket={mockSocket}
|
||||||
|
|
@ -175,67 +175,4 @@ describe('LiveResults', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('displays the submitted answer(s) in a question cell', () => {
|
|
||||||
render(
|
|
||||||
<LiveResults
|
|
||||||
socket={mockSocket}
|
|
||||||
questions={mockQuestions}
|
|
||||||
showSelectedQuestion={jest.fn()}
|
|
||||||
quizMode="teacher"
|
|
||||||
students={mockStudents}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
// Show answers should be enabled
|
|
||||||
const showAnswersSwitch = screen.getByLabelText('Afficher les réponses');
|
|
||||||
// Toggle the display of answers is it's not already enabled
|
|
||||||
if (!(showAnswersSwitch as HTMLInputElement).checked) {
|
|
||||||
fireEvent.click(showAnswersSwitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
mockStudents.forEach((student) => {
|
|
||||||
student.answers.forEach((answer) => {
|
|
||||||
const chosenAnswerElements = screen.getAllByText(answer.answer.join(', '));
|
|
||||||
const chosenAnswerElement = chosenAnswerElements.find((element) => {
|
|
||||||
return element.closest('td')?.classList.contains('MuiTableCell-root');
|
|
||||||
});
|
|
||||||
expect(chosenAnswerElement).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('highlights the cell of the selected question', () => {
|
|
||||||
render(
|
|
||||||
<LiveResults
|
|
||||||
socket={mockSocket}
|
|
||||||
questions={mockQuestions}
|
|
||||||
showSelectedQuestion={jest.fn()}
|
|
||||||
quizMode="teacher"
|
|
||||||
students={mockStudents}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
// Select the first question
|
|
||||||
const questionCell = screen.getByText(`Q${1}`);
|
|
||||||
fireEvent.click(questionCell);
|
|
||||||
|
|
||||||
// Check if the selected question is highlighted
|
|
||||||
expect(questionCell.closest('th')?.classList.contains('selected-question')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Show answers should be enabled by default', () => {
|
|
||||||
render(
|
|
||||||
<LiveResults
|
|
||||||
socket={mockSocket}
|
|
||||||
questions={mockQuestions}
|
|
||||||
showSelectedQuestion={jest.fn()}
|
|
||||||
quizMode="teacher"
|
|
||||||
students={mockStudents}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const showAnswersSwitch = screen.getByLabelText('Afficher les réponses');
|
|
||||||
expect((showAnswersSwitch as HTMLInputElement).checked).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,7 @@ const LiveResultsTableFooter: React.FC<LiveResultsFooterProps> = ({
|
||||||
const answer = student.answers.find(
|
const answer = student.answers.find(
|
||||||
(answer) => parseInt(answer.idQuestion.toString()) === index + 1
|
(answer) => parseInt(answer.idQuestion.toString()) === index + 1
|
||||||
);
|
);
|
||||||
const answerText = answer
|
const answerText = answer ? answer.answer.toString() : '';
|
||||||
? Array.isArray(answer.answer)
|
|
||||||
? answer.answer.join(', ') // Join array elements with a space or another delimiter
|
|
||||||
: "" // never reached
|
|
||||||
: '';
|
|
||||||
const isCorrect = answer ? answer.isCorrect : false;
|
const isCorrect = answer ? answer.isCorrect : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -67,7 +63,6 @@ const LiveResultsTableFooter: React.FC<LiveResultsFooterProps> = ({
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{showCorrectAnswers ? (
|
{showCorrectAnswers ? (
|
||||||
// strips out formatting of answer text here (it will break images, katex, etc.)
|
|
||||||
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate({ format: '', text: answerText }) }}></div>
|
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate({ format: '', text: answerText }) }}></div>
|
||||||
) : isCorrect ? (
|
) : isCorrect ? (
|
||||||
<FontAwesomeIcon icon={faCheck} aria-label="correct" />
|
<FontAwesomeIcon icon={faCheck} aria-label="correct" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue