mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { TemplateOptions, TextChoice, TrueFalse as TrueFalseType } from './types';
|
|
import QuestionContainer from './QuestionContainer';
|
|
import TextType from './TextType';
|
|
import GlobalFeedback from './GlobalFeedback';
|
|
import MultipleChoiceAnswers from './MultipleChoiceAnswers';
|
|
import Title from './Title';
|
|
import { ParagraphStyle } from '../constants';
|
|
import { state } from '.';
|
|
|
|
type TrueFalseOptions = TemplateOptions & TrueFalseType;
|
|
|
|
export default function TrueFalse({
|
|
title,
|
|
isTrue,
|
|
stem,
|
|
correctFeedback,
|
|
incorrectFeedback,
|
|
globalFeedback
|
|
}: TrueFalseOptions): string {
|
|
const choices: TextChoice[] = [
|
|
{
|
|
text: {
|
|
format: 'moodle',
|
|
text: 'Vrai'
|
|
},
|
|
isCorrect: isTrue,
|
|
weight: null,
|
|
feedback: isTrue ? correctFeedback : incorrectFeedback
|
|
},
|
|
{
|
|
text: {
|
|
format: 'moodle',
|
|
text: 'Faux'
|
|
},
|
|
isCorrect: !isTrue,
|
|
weight: null,
|
|
feedback: !isTrue ? correctFeedback : incorrectFeedback
|
|
}
|
|
];
|
|
|
|
return `${QuestionContainer({
|
|
children: [
|
|
Title({
|
|
type: 'Vrai/Faux',
|
|
title: title
|
|
}),
|
|
`<p style="${ParagraphStyle(state.theme)}">${TextType({
|
|
text: stem
|
|
})}</p>`,
|
|
MultipleChoiceAnswers({ choices: choices }),
|
|
GlobalFeedback({ feedback: globalFeedback })
|
|
]
|
|
})}`;
|
|
}
|