diff --git a/client/src/__tests__/components/GiftTemplate/TextType.test.ts b/client/src/__tests__/components/GiftTemplate/TextType.test.ts
index 109852e..40d229d 100644
--- a/client/src/__tests__/components/GiftTemplate/TextType.test.ts
+++ b/client/src/__tests__/components/GiftTemplate/TextType.test.ts
@@ -1,4 +1,4 @@
-import { textType } from "src/components/GiftTemplate/templates/TextTypeTemplate";
+import { FormatTextTemplate } from "src/components/GiftTemplate/templates/TextTypeTemplate";
import { TextFormat } from "gift-pegjs";
describe('TextType', () => {
@@ -8,7 +8,7 @@ describe('TextType', () => {
format: 'moodle'
};
const expectedOutput = 'Hello, world! 5 > 3, right?';
- expect(textType(input)).toBe(expectedOutput);
+ expect(FormatTextTemplate(input)).toBe(expectedOutput);
});
it('should format text with newlines correctly', () => {
@@ -17,7 +17,7 @@ describe('TextType', () => {
format: 'plain'
};
const expectedOutput = 'Hello,
world!
5 > 3, right?';
- expect(textType(input)).toBe(expectedOutput);
+ expect(FormatTextTemplate(input)).toBe(expectedOutput);
});
it('should format text with LaTeX correctly', () => {
@@ -31,7 +31,7 @@ describe('TextType', () => {
// by running the test and copying the "Received string:" in jest output
// when it fails (assuming the output is correct)
const expectedOutput = '';
- expect(textType(input)).toContain(expectedOutput);
+ expect(FormatTextTemplate(input)).toContain(expectedOutput);
});
it('should format text with two equations (inline and separate) correctly', () => {
@@ -41,7 +41,7 @@ describe('TextType', () => {
};
// hint: katex-display is the class that indicates a separate equation
const expectedOutput = ' ? ';
- expect(textType(input)).toContain(expectedOutput);
+ expect(FormatTextTemplate(input)).toContain(expectedOutput);
});
it('should format text with a katex matrix correctly', () => {
@@ -51,7 +51,7 @@ describe('TextType', () => {
format: 'plain'
};
const expectedOutput = 'Donnez le déterminant de la matrice suivante.\\begin{pmatrix}
a&b \\\\
c&d
\\end{pmatrix}';
- expect(textType(input)).toContain(expectedOutput);
+ expect(FormatTextTemplate(input)).toContain(expectedOutput);
});
it('should format text with Markdown correctly', () => {
@@ -61,7 +61,7 @@ describe('TextType', () => {
};
// TODO: investigate why the output has an extra newline
const expectedOutput = 'Bold\n';
- expect(textType(input)).toBe(expectedOutput);
+ expect(FormatTextTemplate(input)).toBe(expectedOutput);
});
it('should format text with HTML correctly', () => {
@@ -70,7 +70,7 @@ describe('TextType', () => {
format: 'html'
};
const expectedOutput = 'yes';
- expect(textType(input)).toBe(expectedOutput);
+ expect(FormatTextTemplate(input)).toBe(expectedOutput);
});
it('should format plain text correctly', () => {
@@ -79,7 +79,7 @@ describe('TextType', () => {
format: 'plain'
};
const expectedOutput = 'Just plain text';
- expect(textType(input)).toBe(expectedOutput);
+ expect(FormatTextTemplate(input)).toBe(expectedOutput);
});
// Add more tests for other formats if needed
diff --git a/client/src/__tests__/components/GiftTemplate/templates/__snapshots__/MultipleChoice.test.tsx.snap b/client/src/__tests__/components/GiftTemplate/templates/__snapshots__/MultipleChoice.test.tsx.snap
index 651b5bc..923d220 100644
--- a/client/src/__tests__/components/GiftTemplate/templates/__snapshots__/MultipleChoice.test.tsx.snap
+++ b/client/src/__tests__/components/GiftTemplate/templates/__snapshots__/MultipleChoice.test.tsx.snap
@@ -40,7 +40,7 @@ exports[`MultipleChoice snapshot test 1`] = `
</div>
<p style="
color: hsl(0, 0%, 0%);
-">Sample Stem</p><span style="
+" class="present-question-stem">Sample Stem</p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
@@ -169,7 +169,7 @@ exports[`MultipleChoice snapshot test with 2 images using markdown text format 1
</div>
<p style="
color: hsl(0, 0%, 0%);
-"><img src="https://via.placeholder.com/150" alt = "Sample Image"/></p><span style="
+" class="present-question-stem"><img src="https://via.placeholder.com/150" alt = "Sample Image"/></p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
@@ -337,7 +337,7 @@ exports[`MultipleChoice snapshot test with Moodle text format 1`] = `
</div>
<p style="
color: hsl(0, 0%, 0%);
-">Sample Stem</p><span style="
+" class="present-question-stem">Sample Stem</p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
@@ -466,7 +466,7 @@ exports[`MultipleChoice snapshot test with image 1`] = `
</div>
<p style="
color: hsl(0, 0%, 0%);
-">Sample Stem with Image</p><span style="
+" class="present-question-stem">Sample Stem with Image</p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
@@ -631,7 +631,7 @@ exports[`MultipleChoice snapshot test with image using markdown text format 1`]
</div>
<p style="
color: hsl(0, 0%, 0%);
-">Sample Stem with Image
+" class="present-question-stem">Sample Stem with Image
</p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
@@ -800,7 +800,7 @@ exports[`MultipleChoice snapshot test with katex 1`] = `
</div>
<p style="
color: hsl(0, 0%, 0%);
-"><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mrow><mi>z</mi><mi>z</mi><mi>z</mi></mrow><mrow><mi>y</mi><mi>y</mi><mi>y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\\frac{zzz}{yyy}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.988em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">yyy</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">zzz</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p><span style="
+" class="present-question-stem"><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mrow><mi>z</mi><mi>z</mi><mi>z</mi></mrow><mrow><mi>y</mi><mi>y</mi><mi>y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\\frac{zzz}{yyy}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.988em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">yyy</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">zzz</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
@@ -929,7 +929,7 @@ exports[`MultipleChoice snapshot test with katex, using html text format 1`] = `
</div>
<p style="
color: hsl(0, 0%, 0%);
-"><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mrow><mi>z</mi><mi>z</mi><mi>z</mi></mrow><mrow><mi>y</mi><mi>y</mi><mi>y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\\frac{zzz}{yyy}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.988em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">yyy</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">zzz</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p><span style="
+" class="present-question-stem"><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mrow><mi>z</mi><mi>z</mi><mi>z</mi></mrow><mrow><mi>y</mi><mi>y</mi><mi>y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\\frac{zzz}{yyy}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.988em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">yyy</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">zzz</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p><span style="
color: hsl(0, 0%, 0%);
">Choisir une réponse:</span>
<div class='multiple-choice-answers-container'>
diff --git a/client/src/components/GiftTemplate/templates/DescriptionTemplate.ts b/client/src/components/GiftTemplate/templates/DescriptionTemplate.ts
index fa4b70d..5e934a7 100644
--- a/client/src/components/GiftTemplate/templates/DescriptionTemplate.ts
+++ b/client/src/components/GiftTemplate/templates/DescriptionTemplate.ts
@@ -1,10 +1,8 @@
import { TemplateOptions } from './types';
import QuestionContainer from './QuestionContainerTemplate';
import Title from './TitleTemplate';
-import { textType } from './TextTypeTemplate';
-import { ParagraphStyle } from '../constants';
-import { state } from '.';
import { Description } from 'gift-pegjs';
+import StemTemplate from './StemTemplate';
type DescriptionOptions = TemplateOptions & Description;
@@ -15,9 +13,7 @@ export default function DescriptionTemplate({ title, formattedStem}: Description
type: 'Description',
title: title
}),
- `
- ${textType(formattedStem)} -
` + StemTemplate({formattedStem}), ] })}`; } diff --git a/client/src/components/GiftTemplate/templates/EssayTemplate.ts b/client/src/components/GiftTemplate/templates/EssayTemplate.ts index 5697846..ba1ac03 100644 --- a/client/src/components/GiftTemplate/templates/EssayTemplate.ts +++ b/client/src/components/GiftTemplate/templates/EssayTemplate.ts @@ -1,11 +1,11 @@ import { TemplateOptions } from './types'; import QuestionContainer from './QuestionContainerTemplate'; import Title from './TitleTemplate'; -import {textType} from './TextTypeTemplate'; import GlobalFeedbackTemplate from './GlobalFeedbackTemplate'; -import { ParagraphStyle, TextAreaStyle } from '../constants'; +import { TextAreaStyle } from '../constants'; import { state } from '.'; import { EssayQuestion } from 'gift-pegjs'; +import StemTemplate from './StemTemplate'; type EssayOptions = TemplateOptions & EssayQuestion; @@ -16,7 +16,7 @@ export default function EssayTemplate({ title, formattedStem, formattedGlobalFee type: 'Développement', title: title }), - `${textType(formattedStem)}
`, + StemTemplate({formattedStem}), ``, diff --git a/client/src/components/GiftTemplate/templates/GlobalFeedbackTemplate.ts b/client/src/components/GiftTemplate/templates/GlobalFeedbackTemplate.ts index 2c5b6d4..e5e4e78 100644 --- a/client/src/components/GiftTemplate/templates/GlobalFeedbackTemplate.ts +++ b/client/src/components/GiftTemplate/templates/GlobalFeedbackTemplate.ts @@ -1,5 +1,5 @@ import { TemplateOptions } from './types'; -import {textType} from './TextTypeTemplate'; +import {FormatTextTemplate} from './TextTypeTemplate'; import { state } from '.'; import { theme } from '../constants'; import { TextFormat } from 'gift-pegjs'; @@ -20,7 +20,7 @@ export default function GlobalFeedbackTemplate({ format, text }: GlobalFeedbackO return (format && text) ? `${textType({format: format, text: text})}
+${FormatTextTemplate({format: format, text: text})}
${textType(formattedStem)}
`, + StemTemplate({formattedStem}), MatchAnswers({ choices: matchPairs }), formattedGlobalFeedback ? GlobalFeedback(formattedGlobalFeedback) : '' ] @@ -66,7 +67,7 @@ function MatchAnswers({ choices }: MatchAnswerOptions): string { .map(({ formattedSubquestion }) => { return `