From 86b127378bc502703a381fec0f1d374f489e6f8e Mon Sep 17 00:00:00 2001 From: "C. Fuhrman" Date: Tue, 14 Jan 2025 11:18:52 -0500 Subject: [PATCH 1/4] Script to backup the mongo db --- export-collections.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 export-collections.bash diff --git a/export-collections.bash b/export-collections.bash new file mode 100644 index 0000000..2914646 --- /dev/null +++ b/export-collections.bash @@ -0,0 +1,10 @@ +#!/bin/bash + +DB_NAME="evaluetonsavoir" +OUTPUT_DIR="/data/db" + +collections=$(mongosh $DB_NAME --quiet --eval "db.getCollectionNames().join(' ')") + +for collection in $collections; do + mongoexport --db=$DB_NAME --collection=$collection --out=$OUTPUT_DIR/$collection.json --jsonArray +done From d18c2c502a0825d194875e983dac5c07e2e7d3e9 Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:37:29 -0500 Subject: [PATCH 2/4] =?UTF-8?q?Button=20pour=20monter=20en=20haut=20de=20l?= =?UTF-8?q?a=20page=20d'=C3=A9diteur=20de=20quiz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Teacher/EditorQuiz/EditorQuiz.tsx | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx b/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx index e17c91c..88311fa 100644 --- a/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx +++ b/client/src/pages/Teacher/EditorQuiz/EditorQuiz.tsx @@ -1,5 +1,5 @@ // EditorQuiz.tsx -import React, { useState, useEffect, useRef } from 'react'; +import React, { useState, useEffect, useRef, CSSProperties } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { FolderType } from '../../../Types/FolderType'; @@ -40,6 +40,26 @@ const QuizForm: React.FC = () => { }; const fileInputRef = useRef(null); const [dialogOpen, setDialogOpen] = useState(false); + const [showScrollButton, setShowScrollButton] = useState(false); + + const scrollToTop = () => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }; + + useEffect(() => { + const handleScroll = () => { + if (window.scrollY > 300) { + setShowScrollButton(true); + } else { + setShowScrollButton(false); + } + }; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); useEffect(() => { const fetchData = async () => { @@ -292,8 +312,32 @@ const QuizForm: React.FC = () => { + {showScrollButton && ( + + )} ); }; +const scrollToTopButtonStyle: CSSProperties = { + position: 'fixed', + bottom: '40px', + right: '50px', + padding: '10px', + fontSize: '16px', + color: 'white', + backgroundColor: '#5271ff', + border: 'none', + cursor: 'pointer', + zIndex: 1000, +}; + export default QuizForm; From f43da4c8ba76b808a5d5d2524437bcafef6b818c Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:07:56 -0500 Subject: [PATCH 3/4] =?UTF-8?q?Risques=20s=C3=A9curit=C3=A9=20dangerouslyS?= =?UTF-8?q?etInnerHTML()=20Fixes=20#192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/AnswerIcon.test.tsx | 5 ++-- .../GiftTemplate/GIFTTemplatePreview.tsx | 3 +- .../MultipleChoiceQuestion.tsx | 5 ++-- .../NumericalQuestion/NumericalQuestion.tsx | 3 +- .../ShortAnswerQuestion.tsx | 3 +- .../TrueFalseQuestion/TrueFalseQuestion.tsx | 3 +- package-lock.json | 28 +++++++++++++++++++ package.json | 5 ++++ 8 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/client/src/__tests__/components/GiftTemplate/templates/AnswerIcon.test.tsx b/client/src/__tests__/components/GiftTemplate/templates/AnswerIcon.test.tsx index b053976..36fcfa8 100644 --- a/client/src/__tests__/components/GiftTemplate/templates/AnswerIcon.test.tsx +++ b/client/src/__tests__/components/GiftTemplate/templates/AnswerIcon.test.tsx @@ -2,10 +2,11 @@ import React from 'react'; import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; import AnswerIcon from '../../../../components/GiftTemplate/templates/AnswerIcon'; +import DOMPurify from 'dompurify'; describe('AnswerIcon', () => { test('renders correct icon when correct is true', () => { - const { container } = render(
); + const { container } = render(
); const svgElement = container.querySelector('svg'); expect(svgElement).toBeInTheDocument(); @@ -20,7 +21,7 @@ describe('AnswerIcon', () => { }); test('renders incorrect icon when correct is false', () => { - const { container } = render(
); + const { container } = render(
); const svgElement = container.querySelector('svg'); expect(svgElement).toBeInTheDocument(); diff --git a/client/src/components/GiftTemplate/GIFTTemplatePreview.tsx b/client/src/components/GiftTemplate/GIFTTemplatePreview.tsx index 4202b80..51dbd3f 100644 --- a/client/src/components/GiftTemplate/GIFTTemplatePreview.tsx +++ b/client/src/components/GiftTemplate/GIFTTemplatePreview.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react'; import Template, { ErrorTemplate } from './templates'; import { parse } from 'gift-pegjs'; import './styles.css'; +import DOMPurify from 'dompurify'; interface GIFTTemplatePreviewProps { questions: string[]; @@ -73,7 +74,7 @@ const GIFTTemplatePreview: React.FC = ({
{error}
) : isPreviewReady ? (
-
+
) : (
Chargement de la prévisualisation...
diff --git a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx index 5f0e57d..4957d11 100644 --- a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx +++ b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx @@ -4,6 +4,7 @@ import '../questionStyle.css'; import { Button } from '@mui/material'; import textType, { formatLatex } from '../../GiftTemplate/templates/TextType'; import { TextFormat } from '../../GiftTemplate/templates/types'; +import DOMPurify from 'dompurify'; // import Latex from 'react-latex'; type Choices = { @@ -39,7 +40,7 @@ const MultipleChoiceQuestion: React.FC = (props) => { return (
-
+
{choices.map((choice, i) => { @@ -56,7 +57,7 @@ const MultipleChoiceQuestion: React.FC = (props) => { (choice.isCorrect ? '✅' : '❌')}
{alphabet[i]}
-
+
{choice.feedback && showAnswer && ( diff --git a/client/src/components/Questions/NumericalQuestion/NumericalQuestion.tsx b/client/src/components/Questions/NumericalQuestion/NumericalQuestion.tsx index 449e4c7..7a9cec7 100644 --- a/client/src/components/Questions/NumericalQuestion/NumericalQuestion.tsx +++ b/client/src/components/Questions/NumericalQuestion/NumericalQuestion.tsx @@ -4,6 +4,7 @@ import '../questionStyle.css'; import { Button, TextField } from '@mui/material'; import textType from '../../GiftTemplate/templates/TextType'; import { TextFormat } from '../../GiftTemplate/templates/types'; +import DOMPurify from 'dompurify'; type CorrectAnswer = { numberHigh?: number; @@ -34,7 +35,7 @@ const NumericalQuestion: React.FC = (props) => { return (
-
+
{showAnswer ? ( <> diff --git a/client/src/components/Questions/ShortAnswerQuestion/ShortAnswerQuestion.tsx b/client/src/components/Questions/ShortAnswerQuestion/ShortAnswerQuestion.tsx index 3f134d6..28639c4 100644 --- a/client/src/components/Questions/ShortAnswerQuestion/ShortAnswerQuestion.tsx +++ b/client/src/components/Questions/ShortAnswerQuestion/ShortAnswerQuestion.tsx @@ -4,6 +4,7 @@ import '../questionStyle.css'; import { Button, TextField } from '@mui/material'; import textType from '../../GiftTemplate/templates/TextType'; import { TextFormat } from '../../GiftTemplate/templates/types'; +import DOMPurify from 'dompurify'; type Choices = { feedback: { format: string; text: string } | null; @@ -28,7 +29,7 @@ const ShortAnswerQuestion: React.FC = (props) => { return (
-
+
{showAnswer ? ( <> diff --git a/client/src/components/Questions/TrueFalseQuestion/TrueFalseQuestion.tsx b/client/src/components/Questions/TrueFalseQuestion/TrueFalseQuestion.tsx index 4597d6f..18b7038 100644 --- a/client/src/components/Questions/TrueFalseQuestion/TrueFalseQuestion.tsx +++ b/client/src/components/Questions/TrueFalseQuestion/TrueFalseQuestion.tsx @@ -4,6 +4,7 @@ import '../questionStyle.css'; import { Button } from '@mui/material'; import textType from '../../GiftTemplate/templates/TextType'; import { TextFormat } from '../../GiftTemplate/templates/types'; +import DOMPurify from 'dompurify'; interface Props { questionContent: TextFormat; @@ -27,7 +28,7 @@ const TrueFalseQuestion: React.FC = (props) => { return (
-
+