mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Fix bug with multiple choice (radio vs checkbox)
Some checks failed
CI/CD Pipeline for Backend / build_and_push_backend (push) Failing after 18s
CI/CD Pipeline for Nginx Router / build_and_push_nginx (push) Failing after 17s
CI/CD Pipeline for Frontend / build_and_push_frontend (push) Failing after 18s
Tests / lint-and-tests (client) (push) Failing after 57s
Tests / lint-and-tests (server) (push) Failing after 1m2s
Some checks failed
CI/CD Pipeline for Backend / build_and_push_backend (push) Failing after 18s
CI/CD Pipeline for Nginx Router / build_and_push_nginx (push) Failing after 17s
CI/CD Pipeline for Frontend / build_and_push_frontend (push) Failing after 18s
Tests / lint-and-tests (client) (push) Failing after 57s
Tests / lint-and-tests (server) (push) Failing after 1m2s
Snapshot update
This commit is contained in:
parent
fc15d2c3bd
commit
3d9015febd
3 changed files with 11 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ const katekMock: TemplateOptions & MultipleChoiceQuestion = {
|
||||||
formattedStem: { format: 'plain' , text: '$$\\frac{zzz}{yyy}$$'},
|
formattedStem: { format: 'plain' , text: '$$\\frac{zzz}{yyy}$$'},
|
||||||
choices: [
|
choices: [
|
||||||
{ formattedText: { format: 'plain' , text: 'Choice 1'}, isCorrect: true, formattedFeedback: { format: 'plain' , text: 'Correct!'}, weight: 1 },
|
{ 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' }
|
formattedGlobalFeedback: { format: 'plain', text: 'Sample Global Feedback' }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,7 @@ exports[`MultipleChoice snapshot test with katex 1`] = `
|
||||||
|
|
||||||
<div class='multiple-choice-answers-container'>
|
<div class='multiple-choice-answers-container'>
|
||||||
<input class="gift-input" type="radio" id="idmocked-id" name="idmocked-id">
|
<input class="gift-input" type="radio" id="idmocked-id" name="idmocked-id">
|
||||||
<span class="answer-weight-container answer-positive-weight">1%</span>
|
|
||||||
<label style="
|
<label style="
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.2em 0 0.2em 0;
|
padding: 0.2em 0 0.2em 0;
|
||||||
|
|
@ -742,15 +742,15 @@ exports[`MultipleChoice snapshot test with katex 1`] = `
|
||||||
" for="idmocked-id">
|
" for="idmocked-id">
|
||||||
Choice 2
|
Choice 2
|
||||||
</label>
|
</label>
|
||||||
<svg data-testid="correct-icon" style="
|
<svg data-testid="incorrect-icon" style="
|
||||||
vertical-align: text-bottom;
|
vertical-align: text-bottom;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: 0.1rem;
|
margin-left: 0.1rem;
|
||||||
margin-right: 0.2rem;
|
margin-right: 0.2rem;
|
||||||
|
|
||||||
width: 1em;
|
width: 0.75em;
|
||||||
color: hsl(120, 39%, 54%);
|
color: hsl(2, 64%, 58%);
|
||||||
" 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>
|
" 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>
|
<span class="feedback-container">Correct!</span>
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@ type AnswerFeedbackOptions = TemplateOptions & Pick<TextChoice, 'formattedFeedba
|
||||||
interface AnswerWeightOptions extends TemplateOptions {
|
interface AnswerWeightOptions extends TemplateOptions {
|
||||||
weight: TextChoice['weight'];
|
weight: TextChoice['weight'];
|
||||||
}
|
}
|
||||||
|
// careful -- this template is re-used by True/False questions!
|
||||||
export default function MultipleChoiceAnswersTemplate({ choices }: MultipleChoiceAnswerOptions) {
|
export default function MultipleChoiceAnswersTemplate({ choices }: MultipleChoiceAnswerOptions) {
|
||||||
const id = `id${nanoid(8)}`;
|
const id = `id${nanoid(8)}`;
|
||||||
|
|
||||||
const isMultipleAnswer = choices.filter(({ isCorrect }) => isCorrect === true).length != 0;
|
const hasManyCorrectChoices = choices.filter(({ isCorrect }) => isCorrect === true).length > 1;
|
||||||
|
|
||||||
const prompt = `<span style="${ParagraphStyle(state.theme)}">Choisir une réponse${
|
const prompt = `<span style="${ParagraphStyle(state.theme)}">Choisir une réponse${
|
||||||
isMultipleAnswer ? ` ou plusieurs` : ``
|
hasManyCorrectChoices ? ` ou plusieurs` : ``
|
||||||
}:</span>`;
|
}:</span>`;
|
||||||
const result = choices
|
const result = choices
|
||||||
.map(({ weight, isCorrect, formattedText, formattedFeedback }) => {
|
.map(({ weight, isCorrect, formattedText, formattedFeedback }) => {
|
||||||
|
|
@ -32,12 +32,12 @@ export default function MultipleChoiceAnswersTemplate({ choices }: MultipleChoic
|
||||||
const inputId = `id${nanoid(6)}`;
|
const inputId = `id${nanoid(6)}`;
|
||||||
|
|
||||||
const isPositiveWeight = (weight != undefined) && (weight > 0);
|
const isPositiveWeight = (weight != undefined) && (weight > 0);
|
||||||
const isCorrectOption = isMultipleAnswer ? isPositiveWeight || isCorrect : isCorrect;
|
const isCorrectOption = hasManyCorrectChoices ? isPositiveWeight || isCorrect : isCorrect;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class='multiple-choice-answers-container'>
|
<div class='multiple-choice-answers-container'>
|
||||||
<input class="gift-input" type="${
|
<input class="gift-input" type="${
|
||||||
isMultipleAnswer ? 'checkbox' : 'radio'
|
hasManyCorrectChoices ? 'checkbox' : 'radio'
|
||||||
}" id="${inputId}" name="${id}">
|
}" id="${inputId}" name="${id}">
|
||||||
${AnswerWeight({ weight: weight })}
|
${AnswerWeight({ weight: weight })}
|
||||||
<label style="${CustomLabel} ${ParagraphStyle(state.theme)}" for="${inputId}">
|
<label style="${CustomLabel} ${ParagraphStyle(state.theme)}" for="${inputId}">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue