Skip to content

Question types

Gergely Sarkozi edited this page Mar 15, 2024 · 2 revisions

There are several question types you can use in your quizzes, and contributing new question types is also easy.

Existing question types

The examples on this page don't utilize any of the advanced formatting options (Markdown, LaTeX, etc), but they are nevertheless supported by each question type.

Flashcard

There is a question and the user must answer it (in their head). Once the user is done, they can reveal the answer and decide whether the answer they thought of in their head is the same as the revealed (correct) answer.

{
  "type": "flash-card",
  "question": "The question",
  "answer": "The correct answer"
}

Multiple choice

The user is presented with a question and a list of possible answers. The user must select all of the correct and none of the incorrect answers.

There must be at least one answer, but there is no upper limit. There are also no restrictions on how many correct answers there can be. A multiple choice question is valid even if all or none of the answers are correct.

{
  "type": "multiple-choice",
  "question": "The question",
  "choices": [
    {
      "content": "A correct choice",
      "correct": true
    },
    {
      "content": "An incorrect choice",
      "correct": false
    },
    {
      "content": "Another correct choice",
      "correct": true
    }
  ]
}

Single choice

The user is presented with a question and a list of possible answers. The user must select the correct answer.

There must be exactly one correct answer, but there is no limit on the number of incorrect answers. A single choice question is valid even if there is just a single (correct) answer and no incorrect answers.

{
  "type": "single-choice",
  "question": "The question",
  "choices": [
    {
      "content": "A correct choice",
      "correct": true
    },
    {
      "content": "An incorrect choice",
      "correct": false
    },
    {
      "content": "Another incorrect choice",
      "correct": false
    }
  ]
}

Creating a new question type

  • First, you have to implement the new question type within src/logic-impl/types.
    • The various classes within src/logic-impl/types/common may help you.
    • Create the necessary data holder classes in a your-type.ts file.
      • The text visible by users should be wrapped in the DisplayableContent class to allow for formatting.
    • Create a parser (extending TypeParser) in the your-type.ts file.
      • Please utilize the type assertion methods defined in the TypeParser base class.
    • Create a Vue component responsible for rendering the question type in the YourType.vue file.
      • For rendering DisplayableContent instances please use the ContentDisplayer component.
  • Then you have to register the newly created question type: call the registerQuestionType function in the src/globals/types.ts source file.