local_testdata is a Moodle local plugin for defining, registering, validating, and later generating reproducible test datasets.
This repository currently contains the first MVP slice:
- Moodle plugin scaffold
- dataset and artifact tracking tables
- dataset schema validation
- generation for users and courses
- generation for enrolments and multichoice questions
- generation for activities
- cleanup for tracked users, courses, enrolments, questions, and activities
- admin dashboard for registered datasets
- admin import and run UI for dataset JSON
- guided builder UI that generates JSON from form choices
- preset buttons for common dataset scenarios
- CLI validation and generation entry points
At this stage, TestData focuses on the first operational slice of the dataset model.
Implemented now:
- register dataset definitions
- validate JSON definitions
- generate Moodle users and courses
- generate enrolments and multichoice questions
- generate activities via Moodle's native module creation flow
- cleanup generated Moodle users, courses, enrolments, questions, and activities
- persist datasets in Moodle
- inspect registered datasets in the admin UI
- validate, save, and generate datasets through an admin form
- build dataset JSON from buttons and form choices before generation
- apply common presets like demo, users-only, and quiz-course
Planned next:
- template registry
- richer activity settings and module-specific presets
- richer cleanup and inspection flows
- guided dataset creation UI
Place this plugin into your Moodle installation as:
local/testdata
Then run the Moodle upgrade process:
php admin/cli/upgrade.phpphp local/testdata/cli/validate.php --config=/path/to/dataset.json
php local/testdata/cli/validate.php --config=/path/to/dataset.json --save
php local/testdata/cli/generate.php --config=/path/to/dataset.json
php local/testdata/cli/clean.php --dataset=demo_datasetFor the local Moodle installation at /Users/moskaliuk/demo/site/moodle/public/local/testdata:
bash bin/deploy-local.shUseful variants:
bash bin/deploy-local.sh --verbose
bash bin/deploy-local.sh --mirror
bash bin/deploy-local.sh --purge
bash bin/deploy-local.sh --upgrade
bash bin/deploy-and-purge.sh
bash bin/deploy-and-purge.sh --container demo-webserver-1
bash bin/deploy-and-upgrade.sh
bash bin/deploy-and-upgrade.sh --container demo-webserver-1
bash bin/deploy-purge-and-upgrade.sh --container demo-webserver-1The deploy step copies the plugin into the local Moodle tree and excludes the DevFlow planning files plus the local helper scripts from deployment.
The upgrade workflow uses /Users/moskaliuk/demo/site/moodle/admin/cli/upgrade.php and can run either with host PHP or inside Docker.
{
"dataset": "demo_dataset",
"description": "Simple MVP dataset",
"users": [
{
"username": "user1",
"firstname": "Test",
"lastname": "User"
}
],
"courses": [
{
"fullname": "Course A",
"shortname": "course-a"
}
]
}The example also shows two supported patterns:
- course-level
questions - course-level
activities - course-level
enrolwith"$all_users"
- The working folder in this workspace is
TestData, but the Moodle component name islocal_testdata. - For a real Moodle installation, the final folder name must be
testdataunderlocal/.