Latest beta of gift, true-false and mc tweaks, stem style

This commit is contained in:
C. Fuhrman 2025-01-25 10:36:07 -05:00
parent 82b904ef82
commit 7dbbfbfe65
7 changed files with 19 additions and 10 deletions

View file

@ -21,7 +21,7 @@
"axios": "^1.6.7", "axios": "^1.6.7",
"dompurify": "^3.2.3", "dompurify": "^3.2.3",
"esbuild": "^0.23.1", "esbuild": "^0.23.1",
"gift-pegjs": "^2.0.0-beta.0", "gift-pegjs": "^2.0.0-beta.1",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"katex": "^0.16.11", "katex": "^0.16.11",
"marked": "^14.1.2", "marked": "^14.1.2",
@ -66,6 +66,9 @@
"vite-plugin-environment": "^1.1.3" "vite-plugin-environment": "^1.1.3"
} }
}, },
"../GIFT-grammar-PEG.js": {
"extraneous": true
},
"node_modules/@adobe/css-tools": { "node_modules/@adobe/css-tools": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz",
@ -7439,9 +7442,9 @@
} }
}, },
"node_modules/gift-pegjs": { "node_modules/gift-pegjs": {
"version": "2.0.0-beta.0", "version": "2.0.0-beta.1",
"resolved": "https://registry.npmjs.org/gift-pegjs/-/gift-pegjs-2.0.0-beta.0.tgz", "resolved": "https://registry.npmjs.org/gift-pegjs/-/gift-pegjs-2.0.0-beta.1.tgz",
"integrity": "sha512-M/U4zue2F9TXGEmIIf+nL9JWwudAR5pK4gLDeF2pFfKDNPF1MoCgCS9Vf37NH0oP+Grc7SJbq8FVUefqPH99NA==", "integrity": "sha512-NFWSu3KjpjKrfnbIu/eQOyQqjCgOd/ONDe3+bKhtTQCrTgQPVoybme9cm8tqBmJz1YynloocrPlv9f2syQl/LQ==",
"dependencies": { "dependencies": {
"pegjs": "^0.10.x" "pegjs": "^0.10.x"
} }
@ -10718,7 +10721,6 @@
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz",
"integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==", "integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==",
"license": "MIT",
"bin": { "bin": {
"pegjs": "bin/pegjs" "pegjs": "bin/pegjs"
}, },

View file

@ -25,7 +25,7 @@
"axios": "^1.6.7", "axios": "^1.6.7",
"dompurify": "^3.2.3", "dompurify": "^3.2.3",
"esbuild": "^0.23.1", "esbuild": "^0.23.1",
"gift-pegjs": "file:../GIFT-grammar-PEG.js", "gift-pegjs": "^2.0.0-beta.1",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"katex": "^0.16.11", "katex": "^0.16.11",
"marked": "^14.1.2", "marked": "^14.1.2",

View file

@ -72,6 +72,11 @@
font-size: 2rem; font-size: 2rem;
font-weight: 500; font-weight: 500;
} }
.present-question-stem {
margin-bottom: 2vh;
}
.preview-container { .preview-container {
margin-bottom: 2vh; margin-bottom: 2vh;
width: 60vw; width: 60vw;

View file

@ -22,7 +22,7 @@ export default function MultipleChoiceTemplate({
type: 'Choix multiple', type: 'Choix multiple',
title: title title: title
}), }),
`<p style="${ParagraphStyle(state.theme)}">${textType(formattedStem)}</p>`, `<p style="${ParagraphStyle(state.theme)}" class="present-question-stem">${textType(formattedStem)}</p>`,
MultipleChoiceAnswers({ choices: choices }), MultipleChoiceAnswers({ choices: choices }),
formattedGlobalFeedback ? GlobalFeedback(formattedGlobalFeedback) : '' formattedGlobalFeedback ? GlobalFeedback(formattedGlobalFeedback) : ''
] ]

View file

@ -44,7 +44,7 @@ export default function Title({ type, title }: TitleOptions): string {
<div style="${Container}"> <div style="${Container}">
<span> <span>
${ ${
title !== null title
? `<span style="${QuestionTitle}">${title}</span>` ? `<span style="${QuestionTitle}">${title}</span>`
: `<span style="${OptionalTitle}"><em>(Sans titre)</em></span>` : `<span style="${OptionalTitle}"><em>(Sans titre)</em></span>`
} }

View file

@ -5,6 +5,8 @@ import GlobalFeedback from './GlobalFeedbackTemplate';
import MultipleChoiceAnswersTemplate from './MultipleChoiceAnswersTemplate'; import MultipleChoiceAnswersTemplate from './MultipleChoiceAnswersTemplate';
import Title from './TitleTemplate'; import Title from './TitleTemplate';
import { TextChoice, TrueFalseQuestion } from 'gift-pegjs'; import { TextChoice, TrueFalseQuestion } from 'gift-pegjs';
import { ParagraphStyle } from '../constants';
import { state } from '.';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
type TrueFalseOptions = TemplateOptions & TrueFalseQuestion; type TrueFalseOptions = TemplateOptions & TrueFalseQuestion;
@ -40,7 +42,7 @@ export default function TrueFalseTemplate({
type: 'Vrai/Faux', type: 'Vrai/Faux',
title: title title: title
}), }),
`<div dangerouslySetInnerHTML={{ __html: ${DOMPurify.sanitize(textType(formattedStem))} }} />`, `<p style="${ParagraphStyle(state.theme)}" class="present-question-stem">${DOMPurify.sanitize(textType(formattedStem))}</p>`,
MultipleChoiceAnswersTemplate({ choices: choices }), MultipleChoiceAnswersTemplate({ choices: choices }),
formattedGlobalFeedback ? GlobalFeedback(formattedGlobalFeedback) : `` formattedGlobalFeedback ? GlobalFeedback(formattedGlobalFeedback) : ``
] ]

View file

@ -35,7 +35,7 @@
"supertest": "^6.3.4" "supertest": "^6.3.4"
}, },
"engines": { "engines": {
"node": "18.x" "node": "20.x"
}, },
"jest": { "jest": {
"testEnvironment": "node", "testEnvironment": "node",