Options
All
  • Public
  • Public/Protected
  • All
Menu

sqc-core-functions

Index

Type Aliases

Choice: { answer: string; id: undefined | string; isCorrect: boolean }

Type declaration

  • answer: string
  • id: undefined | string
  • isCorrect: boolean
Question: { choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]; id: undefined | string; question: string }

Type declaration

  • choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]
  • id: undefined | string
  • question: string

Variables

ChoiceSchema: ZodObject<Choice> = ...

Zod validation schema for Choice

QuestionSchema: ZodObject<Question> = ...

Zod validation schema for Question

Functions

  • createChoice(__namedParameters?: Partial<{ answer: string; id: undefined | string; isCorrect: boolean }>): { answer: string; id: undefined | string; isCorrect: boolean }
  • Create a Choice object with the given parameters. If no parameters are given, default values will be used. The parameters include an ID, answer, and a boolean that indicates whether or not the choice is correct. The default value of isCorrect is false.

    example
    const myChoice = createChoice({
    answer: 'The answer is 42',
    isCorrect: true,
    });
    console.log(myChoice); // Output: { id: '<random uuid>', answer: 'The answer is 42', isCorrect: true }

    Parameters

    • __namedParameters: Partial<{ answer: string; id: undefined | string; isCorrect: boolean }> = {}

    Returns { answer: string; id: undefined | string; isCorrect: boolean }

    • answer: string
    • id: undefined | string
    • isCorrect: boolean
  • createQuestion(__namedParameters?: Partial<Omit<{ choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]; id: undefined | string; question: string }, "choices"> & { choices: Partial<{ answer: string; id: undefined | string; isCorrect: boolean }>[] }>): { choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]; id: undefined | string; question: string }
  • Create a Question object with the given parameters. If no parameters are given, default values will be used. The parameters include an ID, question, and an array of Choice object. The default awswer is an empty choice which is marked as default correct answer.

    example
    const myQuestion = createQuestion({
    question: 'What is the answer to the ultimate question of life, the universe, and everything?',
    choices: [
    { answer: 'I dunno', isCorrect: true },
    { answer: '12', isCorrect: false },
    { answer: '21', isCorrect: false },
    ],
    })
    console.log(myQuestion);

    Parameters

    • __namedParameters: Partial<Omit<{ choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]; id: undefined | string; question: string }, "choices"> & { choices: Partial<{ answer: string; id: undefined | string; isCorrect: boolean }>[] }> = {}

    Returns { choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]; id: undefined | string; question: string }

    • choices: ({ answer: string; isCorrect: boolean; id?: string | undefined; })[]
    • id: undefined | string
    • question: string

Generated using TypeDoc