Skip to content

Activities

An activity is a learner-facing step inside a lesson. It has a kind, a free-form spec (jsonb config), a rubric (jsonb grading), and an ordinal.

kind is one of ten: diagram, document, quiz, code, concept, single_choice, multi_choice, match, order, video. See the lesson model → activity kinds for what each means.

List the activities of a lesson, ordered by ordinal. RLS-scoped.

Inputs:

ArgTypeNotes
lesson_iduuidrequired

Result: { "activities": [ { "id", "lesson_id", "ordinal", "kind", "spec", "rubric" }, … ] }

Fetch one activity (kind, spec, rubric). RLS-scoped.

Inputs:

ArgTypeNotes
activity_iduuidrequired

Result: { "activity": { "id", "lesson_id", "ordinal", "kind", "spec", "rubric" } }

Add an activity to a lesson. Author-role only.

Inputs:

ArgTypeNotes
lesson_iduuidParent lesson.
kindenumOne of the ten kinds above.
ordinal?int ≥ 0Sort position (default 0).
spec?jsonbKind-specific config (default {}).
rubric?jsonbGrading rubric (default {}).

Result: { "success": true, "activity": { "id", "lesson_id", "kind", "ordinal", "spec", "rubric" } }

create_activity → args (single_choice)
{
"lesson_id": "…",
"kind": "single_choice",
"ordinal": 0,
"spec": {
"prompt": "Default Kafka consumer-group delivery guarantee?",
"options": [
{ "id": "a", "label": "Exactly-once" },
{ "id": "b", "label": "At-least-once" }
],
"answer": "b"
}
}

Update an activity’s kind / ordinal / spec / rubric. Author-role only. Only provided fields change.

Inputs:

ArgTypeNotes
activity_iduuidrequired
kind?enumOne of the ten kinds.
ordinal?int ≥ 0
spec?jsonbReplaces the stored spec.
rubric?jsonbReplaces the stored rubric.

Result: { "success": true, "activity": {…} }

Delete an activity. Author-role only. Irreversible.

Inputs:

ArgTypeNotes
activity_iduuidrequired

Result: { "success": true, "deleted": "<activity_id>" }