Exercises

Exercises (assessment activities) are an important part of every learning experience. Kolibri exercises are graded automatically and provide immediate feedback learners. Student answers to be logged and enable progress reports for teachers and coaches. Exercises can also be used as part of lessons and quizzes.

An ExerciseNodes are special kind of content node contains one or more questions. In order to set the criteria for completing exercises, you must set exercise_data to a dict containing a mastery_model field based on the mastery models provided in le_utils.constants.exercises. If no data is provided, ricecooker defaults to m_of_n. If only one of m and n is given, the other takes its value; if neither is, both default to the number of questions, at most 5. For example:

node = ExerciseNode(
    exercise_data={
        'mastery_model': exercises.M_OF_N,
        'randomize': True,
        'm': 3,
        'n': 5,
    },
    ...
)

To add a question to an exercise node, you must first create a question model from ricecooker.classes.questions. Your sushi chef is responsible for determining which question type to create. Here are the available question types:

  • SingleSelectQuestion: questions that only have one right answer (e.g. radio button questions)

  • MultipleSelectQuestion: questions that have multiple correct answers (e.g. check all that apply)

  • InputQuestion: questions that have text-based answers (e.g. fill in the blank)

  • PerseusQuestion: special question type for pre-formatted perseus questions

Each question class has the following attributes that can be set at initialization:

  • id (str): question’s unique id

  • question (str): question body, in plaintext or Markdown format; math expressions must be in Latex format, surrounded by $, e.g. $f(x) = 2^3$.

  • correct_answer (str) or answers ([str]): the answer(s) to question as plaintext or Markdown

  • all_answers ([str]): list of choices for single select and multiple select questions as plaintext or Markdown

  • hints (str or [str]): optional hints on how to answer question, also in plaintext or Markdown

To set the correct answer(s) for MultipleSelectQuestions, you must provide a list of all of the possible choices as well as an array of the correct answers (all_answers [str]) and correct_answers [str] respectively).

question = MultipleSelectQuestion(
    question = "Select all prime numbers.",
    correct_answers = ["2", "3", "5"],
    all_answers = ["1", "2", "3", "4", "5"],
    ...
)

To set the correct answer(s) for SingleSelectQuestions, you must provide a list of all possible choices as well as the correct answer (all_answers [str] and correct_answer str respectively).

question = SingleSelectQuestion(
    question = "What is 2 x 3?",
    correct_answer = "6",
    all_answers = ["2", "3", "5", "6"],
    ...
)

To set the correct answer(s) for InputQuestions, you must provide an array of all of the accepted answers (answers [str]).

question = InputQuestion(
    question = "Name a factor of 10.",
    answers = ["1", "2", "5", "10"],
)

To add images to a question’s question, answers, or hints, format the image path with '![](path/to/some/file.png)' and ricecooker will parse them automatically. An image that fails to download fails the exercise: the run stops, or with the STRICT=False environment variable only that exercise is left out of the upload.

Once you have created the appropriate question object, add it to an exercise object with exercise_node.add_question(question).

QTI packages

ContentNode(uri="package.zip") with a QTI 2.1, 2.2 or 3.0 content package gives one practice quiz per test, with items in test order, or one quiz of all items if the package has no test. QTI 2.x items and tests are converted to QTI 3.0 first. Quizzes default to mastery_model do_all, randomize False and options.modality QUIZ. To change every quiz in the package, set mastery_model, m, n, randomize or options in the node’s extra_fields. "options": {"modality": None} gives plain exercises. Items that are not QTI 2.1, 2.2 or 3.0, fail the QTI 3.0 item schema once converted, or reference media other than images are skipped with a warning. <qti-stylesheet> elements, and elements and attributes outside the QTI 3.0 item schema’s namespaces, are removed from items.

Further reading

  • See also the section Exercise Nodes <nodes.html#exercise-nodes>__ on the nodes page.