diff --git a/client/src/__tests__/components/GiftTemplate/templates/MultipleChoice.test.tsx b/client/src/__tests__/components/GiftTemplate/templates/MultipleChoice.test.tsx index bdecb06..2770267 100644 --- a/client/src/__tests__/components/GiftTemplate/templates/MultipleChoice.test.tsx +++ b/client/src/__tests__/components/GiftTemplate/templates/MultipleChoice.test.tsx @@ -29,7 +29,7 @@ const katekMock: TemplateOptions & MultipleChoiceQuestion = { formattedStem: { format: 'plain' , text: '$$\\frac{zzz}{yyy}$$'}, choices: [ { formattedText: { format: 'plain' , text: 'Choice 1'}, isCorrect: true, formattedFeedback: { format: 'plain' , text: 'Correct!'}, weight: 1 }, - { formattedText: { format: 'plain', text: 'Choice 2' }, isCorrect: true, formattedFeedback: { format: 'plain' , text: 'Correct!'}, weight: 1 } + { formattedText: { format: 'plain', text: 'Choice 2' }, isCorrect: false, formattedFeedback: { format: 'plain' , text: 'Correct!'}, weight: 0 } ], formattedGlobalFeedback: { format: 'plain', text: 'Sample Global Feedback' } }; 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 0a17bf6..d32efd4 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 @@ -733,7 +733,7 @@ exports[`MultipleChoice snapshot test with katex 1`] = ` <div class='multiple-choice-answers-container'> <input class="gift-input" type="radio" id="idmocked-id" name="idmocked-id"> - <span class="answer-weight-container answer-positive-weight">1%</span> + <label style=" display: inline-block; padding: 0.2em 0 0.2em 0; @@ -742,15 +742,15 @@ exports[`MultipleChoice snapshot test with katex 1`] = ` " for="idmocked-id"> Choice 2 </label> - <svg data-testid="correct-icon" style=" + <svg data-testid="incorrect-icon" style=" vertical-align: text-bottom; display: inline-block; margin-left: 0.1rem; margin-right: 0.2rem; - width: 1em; - color: hsl(120, 39%, 54%); - " role="img" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path></svg> + width: 0.75em; + color: hsl(2, 64%, 58%); + " role="img" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg> <span class="feedback-container">Correct!</span> </input> </div> diff --git a/client/src/components/GiftTemplate/templates/MultipleChoiceAnswersTemplate.ts b/client/src/components/GiftTemplate/templates/MultipleChoiceAnswersTemplate.ts index 110465b..76c151d 100644 --- a/client/src/components/GiftTemplate/templates/MultipleChoiceAnswersTemplate.ts +++ b/client/src/components/GiftTemplate/templates/MultipleChoiceAnswersTemplate.ts @@ -13,14 +13,14 @@ type AnswerFeedbackOptions = TemplateOptions & Pick isCorrect === true).length != 0; + const hasManyCorrectChoices = choices.filter(({ isCorrect }) => isCorrect === true).length > 1; const prompt = `Choisir une réponse${ - isMultipleAnswer ? ` ou plusieurs` : `` + hasManyCorrectChoices ? ` ou plusieurs` : `` }:`; const result = choices .map(({ weight, isCorrect, formattedText, formattedFeedback }) => { @@ -32,12 +32,12 @@ export default function MultipleChoiceAnswersTemplate({ choices }: MultipleChoic const inputId = `id${nanoid(6)}`; const isPositiveWeight = (weight != undefined) && (weight > 0); - const isCorrectOption = isMultipleAnswer ? isPositiveWeight || isCorrect : isCorrect; + const isCorrectOption = hasManyCorrectChoices ? isPositiveWeight || isCorrect : isCorrect; return `
${AnswerWeight({ weight: weight })}