Task - Choice

Description

A task bit allowing to create single or multiple choice questions. The answers of users can be automatically evaluated. Also feedback can be given based on the answer pattern.
View Repository
View on NPM

Example

This is an interactive example of the Choice task. You can submit new answers, show a statistic based on thoses answers or modify the task by using the different forms.

Which of the following are programming languages?

Imports

This is a list of all exported components and functions. These are only relevant if you want to use this task in a standalone way.
import {
  Task, TaskSchema,
  ViewForm, EvaluationForm, FeedbackForm,
  evaluate, updateStatistic, Statistic
} from "@bitflow/task-choice"

Usage

We recommand that you wrap this component with the TaskShell component like so, if you want to use the component on its own.
import { TaskShell } from "@bitflow/shell";
import { evaluate, Task } from "@bitflow/task-choice";

const My = () => (
  <TaskShell
    onNext={async () => {}}
    evaluate={evaluate}
    TaskComponent={Task}
    mode="default"
    task={task}
  />
);
            
You can also use this task with the Do component.

Actions

Each task emits different actions, which can be used for capture and replay the solving process. These are defined by the IAction type.

JSON Schema

If you do not want to use the provided forms to create a task object, you can build something yourself which produces a object, which follows this JSON schema.
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "subtype": {
      "type": "string",
      "const": "choice"
    },
    "view": {
      "type": "object",
      "properties": {
        "instruction": {
          "type": "string"
        },
        "variant": {
          "type": "string",
          "enum": [
            "multiple",
            "single"
          ]
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "markdown": {
                "type": "string"
              }
            },
            "required": [
              "markdown"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "instruction",
        "variant",
        "choices"
      ],
      "additionalProperties": false
    },
    "evaluation": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "auto",
            "skip",
            "manual"
          ]
        },
        "enableRetry": {
          "type": "boolean"
        },
        "showFeedback": {
          "type": "boolean"
        },
        "correct": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "a",
              "b",
              "c",
              "d",
              "e",
              "f",
              "g",
              "h"
            ]
          }
        }
      },
      "required": [
        "mode",
        "enableRetry",
        "showFeedback",
        "correct"
      ],
      "additionalProperties": false
    },
    "feedback": {
      "type": "object",
      "properties": {
        "patterns": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "severity": {
                "type": "string",
                "enum": [
                  "error",
                  "warning",
                  "info",
                  "success"
                ]
              }
            },
            "required": [
              "message",
              "severity"
            ],
            "additionalProperties": false
          }
        },
        "choices": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "checkedFeedback": {
                "$ref": "#/properties/feedback/properties/patterns/additionalProperties"
              },
              "notCheckedFeedback": {
                "$ref": "#/properties/feedback/properties/patterns/additionalProperties"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "required": [
        "patterns",
        "choices"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "name",
    "subtype",
    "view",
    "evaluation",
    "feedback"
  ],
  "additionalProperties": false
}