Skip to main content

marimo learning utilities

Project description

marimo-learn

Formative assessment widgets for marimo notebooks. Open in molab

Installation

pip install marimo-learn

Usage in marimo

from marimo_learn import FlashcardWidget, MultipleChoiceWidget, OrderingWidget
from marimo_learn import MatchingWidget, LabelingWidget, ConceptMapWidget

Each widget is an anywidget component. Pass the configuration as constructor arguments; the widget syncs state back to Python via the value traitlet.

Standalone JavaScript bundle

The widgets are also published as an npm package:

npm install marimo-learn

Or load the bundle directly in HTML:

<script type="module" src="marimo-learn.js"></script>

The bundle auto-mounts any .marimo-* divs it finds in the page (see HTML configuration below). You can also call the render functions manually:

import { renderFlashcard, renderMultipleChoice, renderOrdering,
         renderMatching, renderLabeling, renderConceptMap } from 'marimo-learn';

renderMultipleChoice(document.getElementById('target'), {
  question: 'What is 2 + 2?',
  options: ['3', '4', '5'],
  correct_answer: 1,
  lang: 'en',
});

HTML configuration

When the bundle is loaded, autoMount() scans the page for divs with the class marimo-<widget>, parses the HTML markup inside each div, and replaces it with a live widget. This lets you author exercises in plain HTML or Markdown.

Multiple choice

<div class="marimo-multiple-choice" data-correct="2">
  <p>Question text</p>
  <ol>
    <li>Option A</li>
    <li>Option B</li>
    <li>Option C (correct — zero-based index matches data-correct)</li>
    <li>Option D</li>
  </ol>
</div>
  • data-correct — zero-based index of the correct option (required)
  • data-lang — language code, default en

Flashcard

<div class="marimo-flashcard">
  <p>Deck title (optional)</p>
  <dl>
    <dt>Front of card 1</dt>
    <dd>Back of card 1</dd>
    <dt>Front of card 2</dt>
    <dd>Back of card 2</dd>
  </dl>
</div>

Cards are shuffled automatically. data-lang sets the language (default en).

Ordering

<div class="marimo-ordering">
  <p>Question text</p>
  <ol>
    <li>First step (correct position)</li>
    <li>Second step</li>
    <li>Third step</li>
  </ol>
</div>

The <ol> lists items in the correct order. The widget shuffles them before presenting them to the student. data-lang sets the language (default en).

Matching

<div class="marimo-matching">
  <p>Question text</p>
  <table>
    <tr><td>Left item 1</td><td>Right item 1</td></tr>
    <tr><td>Left item 2</td><td>Right item 2</td></tr>
    <tr><td>Left item 3</td><td>Right item 3</td></tr>
  </table>
</div>

Each row defines a matched pair. The right column is shuffled automatically. data-lang sets the language (default en).

Labeling

<div class="marimo-labeling">
  <p>Question text</p>
  <table>
    <tr><td>Text line 1</td><td>Label name</td></tr>
    <tr><td>Text line 2</td><td>Label name</td></tr>
    <tr><td>Text line 3</td><td>Label A, Label B</td></tr>
  </table>
</div>

Column 1 is the text to label; column 2 is the correct label name. Multiple correct labels for one line are written as a comma-separated list. The available label set is derived automatically from the unique names in column 2. data-lang sets the language (default en).

Concept map

<div class="marimo-concept-map">
  <p>Question text</p>
  <table>
    <tr><td>Source node</td><td>relationship</td><td>Target node</td></tr>
    <tr><td>Node A</td>    <td>leads to</td>    <td>Node B</td></tr>
    <tr><td>Node B</td>    <td>leads to</td>    <td>Node C</td></tr>
  </table>
</div>

Each row defines one correct directed edge: source → label → target. The node list and term list are inferred automatically from the table in first-appearance order. data-lang sets the language (default en).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marimo_learn-0.11.0.tar.gz (10.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marimo_learn-0.11.0-py3-none-any.whl (103.6 kB view details)

Uploaded Python 3

File details

Details for the file marimo_learn-0.11.0.tar.gz.

File metadata

  • Download URL: marimo_learn-0.11.0.tar.gz
  • Upload date:
  • Size: 10.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for marimo_learn-0.11.0.tar.gz
Algorithm Hash digest
SHA256 1fdbce7c86170fd04dabbcf9b22d6875ce05185cd85188c321950b87e1721c4c
MD5 fab7335a5e239dfd42592c2db87f01ad
BLAKE2b-256 d7087d88ed12464bc19b264ed17806eb2e66da40cef95b3b9a228cb3efbf10e6

See more details on using hashes here.

File details

Details for the file marimo_learn-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: marimo_learn-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 103.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for marimo_learn-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 843cfe1494a20d1cb32d53e85b2f5867c19cd87ec56ba6b00378782d0e4399fc
MD5 f62b4e5629f7b51b05c720c588c8bd71
BLAKE2b-256 9b03c05e948ae426fd717818096d79b20012dbf08ebe161dacefca260cebc082

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page