MoodlIA Sync reads a source course and writes a plan with the exact changes the target course needs. Nothing is written until you approve that plan; then it applies it and verifies the result. It works with Moodle's standard web services and, where installed, the MoodlIA plugin, choosing per feature.
What it does
- Plan, approve, apply, and verify, as separate steps.
- Stops if either course changed after the plan was made.
- Keeps tokens in environment variables, never in plans or state.
What you need
- Node.js 22.13 or newer.
- Tokens for both Moodle sites (standard web services and/or the MoodlIA plugin).
Installation
Install
Install the command globally:
npm install -g moodlia-syncIf your npm policy blocks install scripts, approve and build the database driver once:
npm approve-scripts better-sqlite3 npm rebuild better-sqlite3Describe both sites in
.moodle-profiles.json; each token is read from the environment variable you name:{ "schema_version": 1, "profiles": { "school_a": { "url": "https://moodle-a.example.edu", "credentials": { "core": { "token_env": "SCHOOL_A_CORE_TOKEN" } } }, "school_b": { "url": "https://moodle-b.example.edu", "credentials": { "core": { "token_env": "SCHOOL_B_CORE_TOKEN" } } } } }
First use
Plan (read-only) and review plan.json:
moodlia-sync plan --source-profile school_a --source-course-id 42 \ --target-profile school_b --target-course-id 108 --plan-file plan.jsonApprove that exact plan, apply it, and verify:
moodlia-sync approve plan.json --yes moodlia-sync apply plan.json --plan-digest <sha256:...> --allow-write moodlia-sync verify --plan-id <plan_id>
Good to know
- Preview: only the content types verified for each site pairing are synchronized; the rest is reported in the plan.
- Try it with test courses before using it with real ones.