UNPKG

@freecodecamp/ui

Version:

The freeCodeCamp.org open-source UI components

30 lines (29 loc) 907 B
import type { QuizQuestionAnswer, QuizQuestionProps } from "../quiz-question"; export interface QuizProps<AnswerT extends number | string> { questions: Question<AnswerT>[]; disabled?: boolean; required?: boolean; } export interface Question<AnswerT extends number | string> { /** * Question text, can be plain text or contain code. * If the question text contains code, use the PrismFormatted component to ensure the code is rendered correctly. */ question: QuizQuestionProps<AnswerT>["question"]; /** * Answer options */ answers: QuizQuestionAnswer<AnswerT>[]; /** * Value of the correct answer */ correctAnswer: AnswerT; /** * Change event handler, called when an answer is selected */ onChange?: (selectedAnswer: AnswerT) => void; /** * Value of the selected answer */ selectedAnswer?: AnswerT; }