Labeling
Labeling Widget for Marimo
LabelingWidget
Bases: AnyWidget
A text labeling widget where students drag numbered labels to text lines.
Attributes:
| Name | Type | Description |
|---|---|---|
question |
str
|
The question text to display |
labels |
list
|
List of label texts (shown on left) |
text_lines |
list
|
List of text lines to be labeled (shown on right) |
correct_labels |
dict
|
Mapping of line indices to lists of correct label indices |
value |
dict
|
Current state with 'placed_labels', 'score', 'total', and 'correct' keys |
Source code in src/marimo_learn/labeling.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
__init__(question, labels, text_lines, correct_labels, lang='en', **kwargs)
Initialize a labeling widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
question
|
str
|
The question text |
required |
labels
|
list[str]
|
List of label texts (e.g., ["Variable declaration", "Function call", "Loop"]) |
required |
text_lines
|
list[str]
|
List of text lines to be labeled (e.g., code lines, sentences) |
required |
correct_labels
|
dict
|
Dict mapping line index to list of correct label indices Example: {0: [0, 1], 2: [2]} means line 0 should have labels 0 and 1, line 2 should have label 2 |
required |
Source code in src/marimo_learn/labeling.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
Example
