Branching and paths¶
Clipboard icons
Commands and prompts on this page use fenced blocks with a copy button (top-right). Click to copy the full text for Terminal, Claude, or Cursor.
LXPack supports non-linear courses with variables and flow rules (v0.2+). If you omit flow, learners move through lessons in list order.
Variables¶
Declare defaults in course.yaml:
HTML interactions can change variables (advanced):
Flow rules¶
Each rule has when (condition) and goto (activity id). Optional from limits when the rule runs:
flow:
- from: choose_path
when:
variable:
eq: [track, advanced]
goto: advanced_lab
- from: choose_path
when:
variable:
eq: [track, basic]
goto: wrap_up
- from: final_quiz
when:
assessment:
passed: final_quiz
goto: wrap_up
| Field | Meaning |
|---|---|
from |
Activity id the learner is on when this rule is evaluated (recommended for variable.eq) |
when |
Condition that must be true |
goto |
Next activity id when the rule matches |
| Condition | Meaning |
|---|---|
variable.eq: [name, value] |
Variable equals value |
assessment.passed: <id> |
Learner passed that quiz |
interaction.done: <lesson_id> |
HTML or SPA lesson tracked completion |
all: [...] / any: [...] |
Combine conditions |
interaction.done and assessment.passed rules infer from when omitted. variable.eq rules without from apply on every navigation (validator warns).
Full example¶
Study examples/branching-demo/ in the repository:
interactions/choose-pathsets the pathcomponentlesson for advanced track- Quiz gate before wrap-up
Validate carefully¶
Errors often mean:
gotopoints to a lessonidthat does not existinteraction.donereferences a lesson that is nothtmlorspa- Flow graph has impossible cycles (validator reports cycles)
Authoring tip¶
Sketch the flow on paper first. Name every lesson id before writing flow. Use Claude with the branching section of Prompts for Claude.
SCORM note¶
SCORM 2004 multi-SCO packages map activities to separate launch pages. Start with SCORM 1.2 while learning branching, unless your LMS requires 2004.