From efef0a33edb9659bb125167052febe850dc93670 Mon Sep 17 00:00:00 2001 From: NouhailaAater Date: Sun, 9 Feb 2025 19:57:40 -0500 Subject: [PATCH] ajout des indices --- .gitignore | 16 ++++ .../GIFTCheatSheet/GiftCheatSheet.tsx | 79 ++++++++++++++++--- .../MultipleChoiceQuestionDisplay.tsx | 16 +++- .../NumericalQuestionDisplay.tsx | 16 +++- .../QuestionsDisplay/QuestionDisplay.tsx | 7 ++ .../ShortAnswerQuestionDisplay.tsx | 15 +++- .../TrueFalseQuestionDisplay.tsx | 15 +++- .../StudentModeQuiz/StudentModeQuiz.tsx | 1 + .../TeacherModeQuiz/TeacherModeQuiz.tsx | 2 + package-lock.json | 6 ++ 10 files changed, 156 insertions(+), 17 deletions(-) create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index 6e8de7b..3d7eed0 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,19 @@ dist .yarn/install-state.gz .pnp.* db-backup/ + + +.V5/ +.EvaluateTonSavoir/ +config/ +applicationhost.config +FileContentIndex/ +*.vsidx +v17/ +.WSuO/ +DocumentLayout.backup.json +DocumentLayout.json +ProjectSettings.json +slnx.sqlite +slnx.sqlite-journal +VSWorkspaceState.json diff --git a/client/src/components/GIFTCheatSheet/GiftCheatSheet.tsx b/client/src/components/GIFTCheatSheet/GiftCheatSheet.tsx index 98d2b96..ab26c1b 100644 --- a/client/src/components/GIFTCheatSheet/GiftCheatSheet.tsx +++ b/client/src/components/GIFTCheatSheet/GiftCheatSheet.tsx @@ -19,13 +19,74 @@ const GiftCheatSheet: React.FC = () => { console.error('Erreur lors de la copie dans le presse-papiers : ', error); }); }; - - const QuestionVraiFaux = "2+2 \\= 4 ? {T}\n// Utilisez les valeurs {T}, {F}, {TRUE} \net {FALSE}."; - const QuestionChoixMul = "Quelle ville est la capitale du Canada? {\n~ Toronto\n~ Montréal\n= Ottawa #Bonne réponse!\n}\n// La bonne réponse est Ottawa"; - const QuestionChoixMulMany = "Quelles villes trouve-t-on au Canada? { \n~ %33.3% Montréal \n ~ %33.3% Ottawa \n ~ %33.3% Vancouver \n ~ %-100% New York \n ~ %-100% Paris \n#### La bonne réponse est Montréal, Ottawa et Vancouver \n}\n// Utilisez tilde (signe de vague) pour toutes les réponses.\n// On doit indiquer le pourcentage de chaque réponse."; - const QuestionCourte ="Avec quoi ouvre-t-on une porte? { \n= clé \n= clef \n}\n// Permet de fournir plusieurs bonnes réponses.\n// Note: La casse n'est pas prise en compte."; - const QuestionNum ="// Question de plage mathématique. \n Quel est un nombre de 1 à 5 ? {\n#3:2\n}\n \n// Plage mathématique spécifiée avec des points de fin d'intervalle. \n Quel est un nombre de 1 à 5 ? {\n#1..5\n} \n\n// Réponses numériques multiples avec crédit partiel et commentaires.\nQuand est né Ulysses S. Grant ? {\n# =1822:0 # Correct ! Crédit complet. \n=%50%1822:2 # Il est né en 1822. Demi-crédit pour être proche.\n}"; + + const QuestionVraiFaux = `Le soleil se lève à l'ouest. +
+ Indice +

La réponse est faux!

+
+{FALSE} +`; + + const QuestionChoixMul = `
+ Indice +

La capitale du Canada est située au sud de l'Ontario.

+
+Quelle ville est la capitale du Canada ? { +~ Toronto +~ Montréal += Ottawa #Bonne réponse ! +}`; + const QuestionChoixMulMany = `
+ Indice +

Les villes du Canada sont toutes situées dans des provinces du pays.

+
+Quelles villes trouve-t-on au Canada? { +~ %33.3% Montréal +~ %33.3% Ottawa +~ %33.3% Vancouver +~ %-100% New York +~ %-100% Paris +#### La bonne réponse est Montréal, Ottawa et Vancouver +}`; + const QuestionCourte = `
+ Indice +

Une clé ou une clef permet d'ouvrir une porte.

+
+Avec quoi ouvre-t-on une porte? { += clé += clef +} +`; + const QuestionNum = `// Question de plage mathématique. +
+ Indice +

Le nombre doit être compris entre 1 et 5.

+
+Quel est un nombre de 1 à 5 ? { +#3:2 +} + +// Plage mathématique spécifiée avec des points de fin d'intervalle. +
+ Indice +

Tout nombre entre 1 et 5 est correct.

+
+Quel est un nombre de 1 à 5 ? { +#1..5 +} + +// Réponses numériques multiples avec crédit partiel et commentaires. +
+ Indice +

Il est né au 19ᵉ siècle.

+
+Quand est né Ulysses S. Grant ? { +# =1822:0 # Correct ! Crédit complet. +=%50%1822:2 # Il est né en 1822. Demi-crédit pour être proche. +} +`; return (

Informations pratiques sur l'éditeur

@@ -85,7 +146,7 @@ const GiftCheatSheet: React.FC = () => { { QuestionNum } - +
@@ -185,7 +246,7 @@ const GiftCheatSheet: React.FC = () => { Attention: l'ancienne fonctionnalité avec les balises {''} n'est plus supportée.

- +

10. Informations supplémentaires

@@ -199,6 +260,6 @@ const GiftCheatSheet: React.FC = () => {

); -}; +}; export default GiftCheatSheet; diff --git a/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx index e5e7b6b..92f1aae 100644 --- a/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx @@ -9,11 +9,23 @@ interface Props { question: MultipleChoiceQuestion; handleOnSubmitAnswer?: (answer: string) => void; showAnswer?: boolean; + isTeacher?: boolean; } const MultipleChoiceQuestionDisplay: React.FC = (props) => { - const { question, showAnswer, handleOnSubmitAnswer } = props; + const { question, showAnswer, handleOnSubmitAnswer, isTeacher } = props; const [answer, setAnswer] = useState(); + + const cleanHtml = (html: string): string => { + if (isTeacher) { + return html.replace(/
.*?<\/details>/gs, ''); + } + return html; + }; + const getCleanStem = (): string => { + const rawHtml = FormattedTextTemplate(question.formattedStem); + return cleanHtml(rawHtml); + }; useEffect(() => { setAnswer(undefined); @@ -28,7 +40,7 @@ const MultipleChoiceQuestionDisplay: React.FC = (props) => { return (
-
+
{question.choices.map((choice, i) => { diff --git a/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx index ac9c83f..80e1b4a 100644 --- a/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx @@ -10,10 +10,11 @@ interface Props { question: NumericalQuestion; handleOnSubmitAnswer?: (answer: number) => void; showAnswer?: boolean; + isTeacher?: boolean; } const NumericalQuestionDisplay: React.FC = (props) => { - const { question, showAnswer, handleOnSubmitAnswer } = + const { question, showAnswer, handleOnSubmitAnswer, isTeacher } = props; const [answer, setAnswer] = useState(); @@ -21,6 +22,17 @@ const NumericalQuestionDisplay: React.FC = (props) => { const correctAnswers = question.choices; let correctAnswer = ''; + const cleanHtml = (html: string): string => { + if (isTeacher) { + return html.replace(/
.*?<\/details>/gs, ''); + } + return html; + }; + const getCleanStem = (): string => { + const rawHtml = FormattedTextTemplate(question.formattedStem); + return cleanHtml(rawHtml); + }; + //const isSingleAnswer = correctAnswers.length === 1; if (isSimpleNumericalAnswer(correctAnswers[0])) { @@ -40,7 +52,7 @@ const NumericalQuestionDisplay: React.FC = (props) => { return (
-
+
{showAnswer ? ( <> diff --git a/client/src/components/QuestionsDisplay/QuestionDisplay.tsx b/client/src/components/QuestionsDisplay/QuestionDisplay.tsx index 8dfa1b3..40bca5c 100644 --- a/client/src/components/QuestionsDisplay/QuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/QuestionDisplay.tsx @@ -11,11 +11,13 @@ interface QuestionProps { question: Question; handleOnSubmitAnswer?: (answer: string | number | boolean) => void; showAnswer?: boolean; + isTeacher?: boolean; } const QuestionDisplay: React.FC = ({ question, handleOnSubmitAnswer, showAnswer, + isTeacher }) => { // const isMobile = useCheckMobileScreen(); // const imgWidth = useMemo(() => { @@ -30,6 +32,7 @@ const QuestionDisplay: React.FC = ({ question={question} handleOnSubmitAnswer={handleOnSubmitAnswer} showAnswer={showAnswer} + isTeacher={isTeacher} /> ); break; @@ -39,6 +42,7 @@ const QuestionDisplay: React.FC = ({ question={question} handleOnSubmitAnswer={handleOnSubmitAnswer} showAnswer={showAnswer} + isTeacher={isTeacher} /> ); break; @@ -50,6 +54,7 @@ const QuestionDisplay: React.FC = ({ question={question} handleOnSubmitAnswer={handleOnSubmitAnswer} showAnswer={showAnswer} + isTeacher={isTeacher} /> ); } else { @@ -58,6 +63,7 @@ const QuestionDisplay: React.FC = ({ question={question} handleOnSubmitAnswer={handleOnSubmitAnswer} showAnswer={showAnswer} + isTeacher={isTeacher} /> ); } @@ -69,6 +75,7 @@ const QuestionDisplay: React.FC = ({ question={question} handleOnSubmitAnswer={handleOnSubmitAnswer} showAnswer={showAnswer} + isTeacher={isTeacher} /> ); break; diff --git a/client/src/components/QuestionsDisplay/ShortAnswerQuestionDisplay/ShortAnswerQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/ShortAnswerQuestionDisplay/ShortAnswerQuestionDisplay.tsx index 50c2261..c2025a7 100644 --- a/client/src/components/QuestionsDisplay/ShortAnswerQuestionDisplay/ShortAnswerQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/ShortAnswerQuestionDisplay/ShortAnswerQuestionDisplay.tsx @@ -8,16 +8,27 @@ interface Props { question: ShortAnswerQuestion; handleOnSubmitAnswer?: (answer: string) => void; showAnswer?: boolean; + isTeacher?: boolean; } const ShortAnswerQuestionDisplay: React.FC = (props) => { - const { question, showAnswer, handleOnSubmitAnswer } = props; + const { question, showAnswer, handleOnSubmitAnswer, isTeacher} = props; const [answer, setAnswer] = useState(); + const cleanHtml = (html: string): string => { + if (isTeacher) { + return html.replace(/
.*?<\/details>/gs, ''); + } + return html; + }; + const getCleanStem = (): string => { + const rawHtml = FormattedTextTemplate(question.formattedStem); + return cleanHtml(rawHtml); + }; return (
-
+
{showAnswer ? ( <> diff --git a/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx index 63b3891..f26d793 100644 --- a/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/TrueFalseQuestionDisplay/TrueFalseQuestionDisplay.tsx @@ -9,13 +9,24 @@ interface Props { question: TrueFalseQuestion; handleOnSubmitAnswer?: (answer: boolean) => void; showAnswer?: boolean; + isTeacher?: boolean; } const TrueFalseQuestionDisplay: React.FC = (props) => { - const { question, showAnswer, handleOnSubmitAnswer } = + const { question, showAnswer, handleOnSubmitAnswer, isTeacher } = props; const [answer, setAnswer] = useState(undefined); + const cleanHtml = (html: string): string => { + if (isTeacher) { + return html.replace(/
.*?<\/details>/gs, ''); + } + return html; + }; + const getCleanStem = (): string => { + const rawHtml = FormattedTextTemplate(question.formattedStem); + return cleanHtml(rawHtml); + }; useEffect(() => { setAnswer(undefined); }, [question]); @@ -25,7 +36,7 @@ const TrueFalseQuestionDisplay: React.FC = (props) => { return (
-
+