Commit 01214b01 authored by Björn Eyselein's avatar Björn Eyselein
Browse files

Fix radio/checkbox

parent 1ed6483d
type CardType = 'Vocable' | 'Text' | 'Blank' | 'Choice';
type CorrectnessType = 'Correct' | 'Optional' | 'Wrong';
function shuffleArray<T>(array: T[]): T[] {
let newArray: T[] = array.slice(0);
......@@ -27,7 +29,7 @@ interface BlanksAnswerFragment {
interface ChoiceAnswer {
answerId: number;
answer: string;
correct: boolean;
correctness: CorrectnessType;
}
interface Flashcard {
......
......@@ -19,7 +19,8 @@ function buildAnswerFragments(answerFragments: BlanksAnswerFragment[]): string {
}
function buildChoiceAnswers(choiceAnswers: ChoiceAnswer[]): string {
const choiceInputType: string = choiceAnswers.filter(ca => ca.correct).length > 0 ? 'radio' : 'checkbox';
const numOfCorrectAnswers = choiceAnswers.filter(ca => ca.correctness !== 'Wrong').length;
const choiceInputType: string = numOfCorrectAnswers == 1 ? 'radio' : 'checkbox';
return shuffleArray(choiceAnswers).map(choiceAnswer => `
<p class="choiceParagraph">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment