This repository contains spike code from Moodle related experimentation for the RAISE project. As such, everything here should be considered as quick and dirty prototypes created to better understand and / or demonstrate potential capabilities.
The following table describes the directories in this repo:
Directory | Description |
---|---|
moodle |
Docker files for building development Moodle images that can be deployed locally using docker compose or on Kubernetes using helm |
deploy |
Deployment automation code |
plugins |
Moodle plugins |
services |
Ancillary services used to implement / demonstrate functionality |
demos |
Miscellaneous code / files used for demos |
scripts |
Utility / helper scripts |
You can use the following commands to get a basic local environment running using docker compose
(you may want to modify values in .env
beforehand):
$ docker compose up -d
$ docker compose exec moodle php admin/cli/install_database.php --agree-license --fullname="Local Dev" --shortname="Local Dev" --summary="Local Dev" --adminpass="admin" --adminemail="[email protected]"
The site will then be available at http://localhost:8000/.
To log into the server go to http://localhost:5050/
Log in:
- Email: [email protected]
- Password: root
On the home page click "Add new server" Give the new server a name. Example: "my_db"
Go to the connection tab and set the following perameters
- Hostname/address: postgres
- Port: 5432
- Username: moodle
- Password: moodledbpassword
Click "Save"
You can configure your local development environment to debug Moodle in VScode using the following steps:
- Install xdebug in your environment
- Install the php-debug extension in VS Code
- Create a
launch.json
with an appropriatepathMappings
if you want to set break points in the editor:
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/admin/tool/events": "${workspaceFolder}/plugins/events"
}
}
- Setup
moodle
container for debugging:
$ MOODLE_TARGET=dbg docker compose up --build -d
If you are debugging / developing, you may want to modify the following settings within Moodle as well:
Site Administration -> Development -> Debugging
: Set "Debug messages" to "Developer"Site Administration -> Appearance -> AJAX and Javascript
: Clear the flag for "Cache Javascript"
It's sometimes useful to be able to see the emails Moodle is trying to send to users. The environments in this repo configure MailHog so developers can inspect these emails without a real SMTP setup. In a local docker environment, you can navigate to http://localhost:8025 to see the MailHog web interface. If you have enableMailhog
enabled for a Kubernetes deployment, the interface can be opened on your development machine by using kubectl
to port forward:
$ kubectl port-forward $(kubectl get po -l "app=raise-spikes-mailhog-<deploymentName>" -o name) 8025:8025
Tests can be invoked after setting up phpunit
:
$ docker compose exec moodle php admin/tool/phpunit/cli/init.php
$ docker compose exec moodle vendor/bin/phpunit --testsuite local_raisecli_testsuite
$ docker compose exec moodle vendor/bin/phpunit --testsuite local_raise_testsuite
The environment in this repo can be used to create a .mbz
file for git storage of course backup data from an arbritrary instance. All this script really does is load the content in a clean database and re-export using automated steps for consistency.
NOTE: Running this script will delete all of the data in your local Moodle instance.
Example steps:
$ ./scripts/gitify_mbz.sh -i input.mbz -o output.mbz